The full name of the GC is garbage collection, the Chinese name Garbage collection, which is a function of. NET for memory management. The garbage collector tracks and reclaims objects allocated in managed memory and periodically performs garbage collection to reclaim memory allocated to objects that do not have a valid reference. The GC automatically occurs when the memory request is not satisfied with available memory.
The full name of the GC is garbage collection, the Chinese name Garbage collection, which is a function of. NET for memory management. The garbage collector tracks and reclaims objects allocated in managed memory and periodically performs garbage collection to reclaim memory allocated to objects that do not have a valid reference. The GC automatically occurs when the memory request is not satisfied with available memory.
When garbage collection is done, the garbage collector searches the managed object in memory first, then searches for the referenced object from managed code and marks it as valid, then releases the object that is not marked as valid and reclaims the memory, and finally collates the memory to move the valid objects together. This is the four steps of the GC.
From the above, GC is very bad for performance, so generally this kind of thing is still as good as possible.
To reduce some of the performance impact,. NET GC Support object Aging, or the concept of generational, generation is the object in memory relative to the current period of measurement units, the object's algebra or the existence of time to describe the generation of objects. Current. NET's garbage collector supports three generations. Each time a GC is made, objects that are not recycled automatically ascend a generation. Objects that are created more recently belong to newer generations, which are lower than the algebra of objects created earlier in the application life cycle. Objects in the most recent generation are located in the 0 generation. At each GC time, the objects in the 0 generation are recycled first, and the higher algebra objects are recycled only if the lower algebraic objects are not satisfied with the requirements after the collection is complete.