Good explanation Ferenc.

Yeah I think there's a lot of misunderstandings going on with weak/soft
references and how the garbage collector works. Weak/soft references is not
some kind of solution to the cyclic reference problem. The GC takes care of
that already. You can use whatever OOP patterns with whatever reference
graphs you like Lars, the GC will free the entire structure as soon as the
cyclic collector runs after you are not referencing it anymore. You might
have become a bit confused with my last post where I explained how one could
theoretically hack together a soft reference implementation by using weak
references and some properties of cyclic collection. Also property access
performance is off-topic.

- Weak references solves the loose coupled object indexing problem. "I need
this reference as long as it's referenced somewhere else."
- Soft references solves the caching problem. "I need this reference as long
as we have plenty of memory available."
- The GC solves the cyclic reference problem (since 5.3).

~Hannes

Reply via email to