Re: How to allocate and delegate; or how to keep GC and the static analyzer happy
Re: How to allocate and delegate; or how to keep GC and the static analyzer happy
- Subject: Re: How to allocate and delegate; or how to keep GC and the static analyzer happy
- From: Jens Alfke <email@hidden>
- Date: Sat, 10 Oct 2009 12:38:07 -0700
On Oct 10, 2009, at 2:25 AM, Glen Low wrote:
Not necessarily. In a pathological but presumably legit case,
whatever happens in initDelegate: might only form a weak reference
to the Something object, thus the Something object would be subject
to GC.
That's true, although unlikely. In that case you could create an
instance variable of the owning object, to point to the Something
object.
Or the thread etc. could somehow fail and never call
finishWithSomething: (thus leaking the Something object).
I don't think you mean "leak" there; if the thread exits, the
Something object would just be collected.
The Something method that runs on the thread should have an @try block
around it, so that if anything goes wrong it can clean up (including
calling back into your main object) before it finishes.
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden