see the garbage collection principle of C-sharp on the Internet, using the concept of big and small heap and generation, big and small heap is easy to understand. As far as I understand it, every time there is no recycling, it is pressed to the next generation. At this time, I feel that it has already moved, but I have freed up a larger piece of continuous space, and only one generation is recycled at a time. In this way, when the memory is not enough to recycle, the number of moves is reduced because only this generation is recycled.
I wonder if my understanding of generations is correct. Please correct it.
finally, I would like to ask, how does the principle of garbage collection help our code, and how can we use the principle of garbage collection to improve our code?