On Jun 2, 2010, at 10:39 AM, Jerry Krinock wrote:

> I allocate an object Foo on the main thread.  Then I spin off a secondary 
> thread and give it a long task to do there, but immediately release the 
> object, on the main thread.  I expect that the -release invoke -dealloc 
> immediately, on the main thread.

Why? If that were so, the secondary thread would crash when it messaged the 
now-dealloced object. By telling the object to do something on a secondary 
thread, you’re implicitly requesting that the object stay alive until that 
operation finishes. Right?

>  To my amazement, the object is not deallocced until the task is finished, 
> and to my further amazement, the dealloc method runs on the secondary thread.

It’s really not a good idea to obsess over the details of when objects get 
dealloced, unless of course you’re running into dealloced-object crashes or 
memory leaks.

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to