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: Charles Yeomans <charles at declareSub dot com>
Date: Mon, 31 Dec 2007 20:08:47 -0500
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> <3C9E9382-6D09-482B-AD65-6A017E856616 at oxalyn dot com> <E7E70A12-4A48-4BC1-8647-0932BF2660E8 at sentman dot com> <31becf620712311442o673e26f5ra4bf1feaa11e2263 at mail dot gmail dot com> <6BACDCE4-F31F-4409-ADC3-C19482AFBF2C at inspiringapps dot com> <64455E6E-EF9B-46CA-882B-166DC13AFFED at sentman dot com>
On Dec 31, 2007, at 6:25 PM, James Sentman wrote:

>
> On Dec 31, 2007, at 5:46 PM, Joe Strout wrote:
>
>> On Dec 31, 2007, at 3:42 PM, Adam Shirey wrote:
>>
>>> Not so. The reason they hang around in memory is because sockets
>>> are a
>>> special case and are not destroyed even when their reference is
>>> lost. See
>>> Aaron's Socket Readme: "One of the new features of sockets in
>>> REALbasic 5.0is the ability to orphan a socket... The socket will
>>> continue to live and stay connected, even though there is nothing
>>> owning a reference to it." This has been a feature of sockets for a
>>> few years now.
>>
>> That's true, but it's ALSO true that any objects with any references
>> to them (including circular ones) will continue to hang around and
>> not be destroyed.
>
>
> heh, so I picked a bad example using a socket  as that is a special
> case. Threads are also a special case for the same reason. It almost
> feels to me like a timer should be a special case too, keeping a self
> reference until it fires, or forever as long as it's mode is 2.
> Wouldn't you put a timer in the same list of special cases as a socket
> and a thread?


Are threads a special case?  While the thread is running, its  
reference count is incremented, and when Run exits, its reference  
count is decremented, same as any other object, including Timers.  But  
a socket's reference count is incremented when its Connect method is  
called, and decremented only around the time that the Error event  
handler is called.  This seems more special, although I've come to  
decide that it's a better idea than I once thought.  I wish the  
documentation were more explicit about it, though...

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