Mono 中数组分配的内存未释放 (C#)

Memory Not Release for Array asignment in Mono (C#)

在我的 C# 程序中,我有一个函数,我创建了长度为 1000000 的字节数组,当函数执行时,内存显示内存使用量增加了 1MB。 问题就出在这里,函数返回后,函数中分配的1MB内存没有释放,为什么????

垃圾收集器不会立即释放内存,但

Garbage collection occurs when one of the following conditions is true:

The system has low physical memory. This is detected by either the low memory notification from the OS or low memory indicated by the host.

The memory that is used by allocated objects on the managed heap surpasses an acceptable threshold. This threshold is continuously adjusted as the process runs.

The GC.Collect method is called. In almost all cases, you do not have to call this method, because the garbage collector runs continuously. This method is primarily used for unique situations and testing.

您可以找到更多 here