The full name of GC is garbage collection. The Chinese name is garbage collection, which is a function of Memory Management in. net. The garbage collector tracks and recycles the objects allocated in the managed memory, and periodically recycles the memory allocated to objects not effectively referenced. GC is automatically executed when the available memory cannot meet the memory request.
During garbage collection, the garbage collector first searches for hosted objects in the memory, then searches for referenced objects in the managed code and marks them as valid, then release the objects not marked as valid and reclaim the memory. Finally, sort out the memory to move the valid objects together. This is the four steps of GC.
As can be seen from the above, GC has a great impact on performance, so it is better to avoid this problem as little as possible.
To reduce performance impact ,.. Net GC supports object aging, or the concept of generational generation. Generation refers to the measurement unit of the object in the memory relative to the current period. The object algebra or the current period indicates the generation of the object. Currently, the. NET Garbage Collector supports three generations. For each GC, objects that are not recycled are automatically upgraded to the next generation. Recently created objects belong to a newer generation, which is lower than the algebra of objects created earlier in the application lifecycle. Objects in the most modern era are in the middle of the zero generation. During each GC, the zero-generation objects are recycled first. The objects with higher algebra are recycled only when the objects with lower algebra still cannot meet the requirements.
Another: can refer to Wang Yonggang's article "garbage collection interesting history", see http://www.contextfree.net/wangyg/ B /tech_his/gc_history.html