On Dec 31, 2007, at 10:07 AM, Eric Williams wrote:
>> Assuming Window1 doesn't go out of scope, objects A through F will
>> all be
>> available. If you then destroy the Window1->ObjD reference, objects
>> D-F --
>> even though they reference each other -- are no longer available
>> and will be
>> destroyed. This, of course, assumes you don't have any other
>> references
>> somewhere.
>
I'd have to run some tests to see if this was true, I can say that
historically this has NOT been true and would have been an upgrade
somewhere to the reference counting system.
But apart from that I agree that this particular use of circular
references might be fishy ;) That being said there is nothing wrong
with circular references! I use them all the time for similar things,
a timer that stores a reference to it's socket for example so that it
can signal a timeout and the socket maintains a reference to the timer
so that it can cancel or reset it. This is a circular reference and if
you just kill the socket and set it's reference in whatever list you
hold them in to nil that socket and it's timer will hang around lost
in memory forever because they still reference each other. Just
because you no longer have a way to get to those references doesn't
make then any less valid as far as reference counting is concerned.
You just need to have close or other methods that you can use to break
the references and set them to nil. And you cannot use the destructor
methods for this as they will only fire once all references have
already been destroyed by something else. So circular references are
both good, valid and sometimes necessary, you just have to remember to
break them yourself.
Thanks,
James
James Sentman http://sentman.com
http://MacHomeAutomation.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|