I'm aware that the .net garbage collector detects cyclic references but I was wondering whether cyclic references may cause objects to stay longer than necessary.
I have a cyclic reference in my ASP.NET app (an intended one for performance related reasons), can I get away with that?
Regards
It doesn't take the CLR any longer to remove a cyclic reference than a non-cyclic reference. The CLR uses a combination of techniques to garbage collect. The quick version though is it starts with all rooted objects (objects on the stack, or held with a strong GC handle). Any object that is reachable from these objects is alive. Anything else will be collected. A cyclic reference won't affect the results of this algorithm other than the CLR has to make sure to check for them and not walk in circles
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