7 ms·
Reference count based GC? How would you deal with circular reference?
by schumihan 16y ago
Reference count based GC? How would you deal with circular reference?
- eru 16y agoYou don't. You'd avoid creating circular structures as much as possible. You can get pretty far that way.
- schumihan 16y agoIt's very difficult to avoid it when thing goes complicating. A may reference B, B may reference C, ... and somewhere, X may reference back to A. If this strategy makes sense for big project, many hackers work with C++ can use it either, as the performance overhead is very low. But in the real world, reference-count based GC just has limited usage.
- eru 16y ago> But in the real world, reference-count based GC just has limited usage. And in theory it doesn't fare much better. Proper garbage collection can have better performance, and does the Right Thing.
- xsmasher 16y agoRetain your children but not your parents; or do you mean a group of "peers" who retain each other? They should probably be in some kind of collection that retains them All.