realbasic-nug
[Top] [All Lists]

Re: Circular reference powers used for good?

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Circular reference powers used for good?
From: "Adam Shirey" <adam dot shirey at gmail dot com>
Date: Mon, 31 Dec 2007 08:09:14 -0600
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <1F31400A-2192-40FA-B482-EAAD05F0C530 at oxalyn dot com>
On Dec 31, 2007 12:59 AM, Eric Williams <eric at oxalyn dot com> wrote:

Can I set up the timer with a property "myself as Timer" to make sure
> it doesn't go out of scope? Then, in the Timer's Action event, I can
> set the myself property to nil and it should just evaporate after the
> event ends (because no other object will hold a reference to it).
>


If I understand you correctly, this won't work. You can't simply reference
to an object somewhere and expect that reference to keep its foot in the
door, especially not a self-reference. As I understand RB's reference
counter, it will cleanup all objects that have no references (which you're
avoiding here), but it'll also find dead groups of objects that have no
other references. For example, consider the following set of objects and
references:

Window1->ObjA
Window1->ObjD
ObjA->ObjB
ObjA->ObjC
ObjB->ObjC
ObjD->ObjE
ObjE->ObjF
ObjF->ObjD

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.



-- 
-Adam
dingostick.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

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


<Prev in Thread] Current Thread [Next in Thread>