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: Eric Williams <eric at oxalyn dot com>
Date: Mon, 31 Dec 2007 07:07:18 -0800
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> <31becf620712310609n6bc59eebt909110f741481fc7 at mail dot gmail dot com>
On Dec 31, 2007, at 6:09 AM, Adam Shirey wrote:

> 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.

Are you sure about this? Seems like it would be fairly  
computationally complex for the runtime to figure out that D-F are  
isolated and can be destroyed.

Anyway, I've been convinced by other posters that it's a bad idea  
anyway... thanks to all!

Eric Williams
Oxalyn Software
http://software.oxalyn.com/

AE Monitor
http://software.oxalyn.com/AEMonitor/


_______________________________________________
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>