Documents worth Reference: Http://www.jb51.net/article/37214.htm.
. NET Memory Management process:
The managed heap assumes that the memory is infinitely large and linearly continuously allocates memory;
When the actual memory is not enough to use, traverse the managed heap to the resource and mark the expired resource;
Compresses the managed heap after the tagged resource is removed (again from the beginning), adjusting the heap pointer to the beginning of the free memory;
Other:
Garbage collection is primarily and Microsoft recommends that the CLR do it itself, and it is not recommended to use GC. Collect directive;
You are responsible for the recycling of unmanaged resources:
- Finalize: Recycles unmanaged resources within Finalize to ensure that the CLR calls Finalize to reclaim unmanaged resources when memory is reclaimed;
- Dispose: To provide an explicit interface, the primary motive for using Dispose is to mate with using, and the compiler will automatically generate a try.finally block for the using, and the compiler will convert the variables in the using to IDispose and call the Di at finally Spose;
C # Dispose Finalize