Garbage collection GC and garbage collection gc
Objects recycled by the garbage collector: The Garbage Collector only recycles the memory in the managed heap. What kind of objects will be recycled? No variable reference object. Objects without variable reference can be recycled (null. When can it be recycled? Not sure. When the program needs new memory, it starts to recycle it. GC. Collect (); // manually call the garbage collector. We do not recommend that you use this function. During garbage collection, it will be paused (for a short time) for the program to automatically perform GC. Garbage collection-for the first garbage collection of three generations, GC will increase the memory of three generations if there is no memory to be recycled. when the memory is insufficient, an exception is thrown .. the mark-and-compact mechanism in. net (mark and compression). It is assumed that all objects are junk at the beginning. Find all objects, check whether they are spam, mark them as non-spam objects, and use Dispose () to spam other resources ()