On 6-Jan-07, at 3:31 AM, Guyren Howe wrote:
On Jan 6, 2007, at 1:16 AM, Mars Saxman wrote:
It's actually pretty trivial to implement weak references with a
plugin, all
you need to do is return the object without locking it.
This is trivial only because it leaves the hard part of the
problem unsolved. When the object reaches the end of its life, all
of these fake "weak references" will become dangling references,
pointing at an object which no longer exists. Breaking the memory
management system like this is not a good idea unless you have too
much free time and want to spend it solving tricky bugs.
Surely, it would still be useful if you know about this and take
account of it.
I keep Lock/Unlock methods handy for "emergencies" but I never end up
using them. The problem with unlocking objects manually is that
you're not creating weak refs - you end up with a bunch of strong
refs, and when any one of them goes out of scope they *all* go bad.
Some fancy code in the destructor might be able to handle this
situation in the simplest of cases but it's actually much ickier (and
much more dangerous) than breaking cyclical refs manually. I've been
down this road before...
Frank.
<http://developer.chaoticbox.com/>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>