realbasic-nug
[Top] [All Lists]

Re: Dangerous deallocation/circular reference...

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Dangerous deallocation/circular reference...
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Thu, 11 Jul 2002 13:42:13 -0500
At 11:01 AM -0700 7/11/02, Brady Duga wrote:

So, my question is, is this safe?

Yes.

I am worried because the reference count of the Tickler becomes 0 from a call the Tickler is making.

No, it doesn't. You said that you nil the reference TO the Tickler. The Tickled object still has a reference to it -- it must, since it invoked the Tickle method somehow.

And in fact, as you've described it, the Tickled object won't go away at all. The Tickler still has a reference to it, so until the Tickler object dies (which presumably won't be until the app exits), anything it has a reference to will stay alive too.

So, what you need to do is tell the Tickler to release its reference to the object that no longer needs tickles. Then, the object will be destroyed. And yes, this is safe.

Cheers,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout           REAL Software, Inc.                |
|    joe at realsoftware dot com       http://www.realsoftware.com        |
`------------------------------------------------------------------'


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