Or I might ask with newer GCs does it matter?
If it does then is it desirable to manage links between nodes through a lookup table or using weak references ( yet more memory ), or is it fine just to have all the nodes point to each other. This is assuming I have a "dispose" method where node or link removal sets all references to it to null.
The issue is if there is a large database in ram, would it be a drastic hit on GC performance if it has to evaluate a lot of long random cycles in the graph? or not?
The mark and sweep approach to garbage collection is totally insensitive to the topology of object graphs. As soon as it reaches an already marked object, it assumes all its referents are marked as well, so you can't do much harm no matter how you design your structure.
My advice is to be obsessive about keeping your code as natural a fit to the problem as possible, and quite lax about any other concerns. When you hit a real performance/memory problem, only then comes a time when you stop and think about optimization.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With