• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Delayed -dealloc occurs on worker thread if object is "working". How?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delayed -dealloc occurs on worker thread if object is "working". How?


  • Subject: Re: Delayed -dealloc occurs on worker thread if object is "working". How?
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 2 Jun 2010 11:12:44 -0700

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

References: 
 >Delayed -dealloc occurs on worker thread if object is "working". How? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: The Unadopted Protocol
  • Next by Date: Re: The Unadopted Protocol
  • Previous by thread: Re: [SOLVED] Delayed -dealloc occurs on worker thread if object is "working".
  • Next by thread: NSNumberFormatter setLocalizesFormat, docs wrong or implementation wrong?
  • Index(es):
    • Date
    • Thread