On Apr 11, 2007, at 10:12 AM, Stephen Dodd wrote:

> At 08:21 -0500 11/4/07, Dr Gerard Hammond wrote:
>> Each child needs to clean up it's link to the parent.
>> Just call your own child.cleanup when closing the parent (ie in the
>> _parent's_ destructor)
>
>
> This sounds a great cure for WeakRef which feels unnatural to me,
> but, I'm confused!
>
> If I set EggCarton = nil, won't that kill the EggCarton and the last
> references to the Eggs thereby eventually garbaging the Eggs. Thus no
> need for a child.cleanup.  Does Nil take care of this problem?

Not if the EggCarton and its Eggs hold (strong) references to each  
other.

>
> If I let EggCarton go out of scope, say in the main application, it
> won't be garbaged because the Eggs still hold a reference to it.
> Thus no kill, no destructor, no child.cleanup.


Probably, depending on your code.


There are at least three articles on my web site that attempt to  
explain this sort of thing.

<http://www.declaresub.com/article/35/the-weakref-class>
<http://www.declaresub.com/article/7/realbasic-memory-management>
<http://www.declaresub.com/article/8/objects-and-object-references>

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to