How to solve the problem of cyclic invocation by train algorithm

Let"s not talk about the principle of the train algorithm here.
the train algorithm is the gc algorithm used by the G1 collector

clipboard.png

D _ C are three objects that need to be called to each other. There are no other citations. But when the algorithm scans the first block of memory, D has a reference to E, E has a reference to c, and c has a reference to D. Both D and E will remain. On the second scan, C also has a reference to D and is preserved. Isn"t it true that the garbage has not been recycled at all

Mar.14,2021

what train algorithm noun does not quite understand, in my opinion, this is a circular reference problem. In some garbage collection algorithms, circular references do cause memory leaks.


you can refer to Progressive garbage Collection: train algorithm

Menu