C # Circular Impact on GC Performance

Possible duplicate:
Garbage collector and circular link

Is there any effect on the performance of the GC if the objects have a circular reference but are not tied to any root otherwise and are therefore ripe for the GC?

Will there be any benefit from a weak reflex in one direction?

+4
source share
3 answers

If objects cannot be reached from the root, they will not go through, so circular reference will not be a problem.

+3
source

Is there any impact on GC performance if objects have a circular reference

Not. The sweep process stops when it encounters an already visited instance. There is no difference with non-circular structures.

but otherwise not tied to any root, and therefore ripe for GC?

In this case, they will not be visited at all, which makes the number of cross-references completely useless.

+4
source

Is there any effect on the performance of the GC if the objects have a circular reference but are not tied to any root otherwise and are therefore ripe for the GC?

Nope. In principle, both objects will have the right to garbage collection if there are no strong links ... you do not need to worry about that.

+3
source

Source: https://habr.com/ru/post/1414201/


All Articles