Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Releasing Objects Allocated in Different Autorelease Pool




On 28/07/2006, at 1:03 PM, Eric Blanpied wrote:

I've got a process on a separate thread which creates objects. This process has it's own autorelease pool, as the docs it seem to recommend. When I release these objects later on, it's done from the main thread. Watching the app in ObjectAlloc, I can see that these objects are never going away, and the various objects they reference don't seem to be getting deallocated, either.

Can someone explain the correct way to do this, please?

Thanks

-eric

There's nothing complicated about autorelease pools. When you release the pool, all queued objects in the pool get sent a release message. An object is queued in the thread's current release pool by sending an object the autorelease message. It doesn't matter which thread release is called in.


If your thread is going to be hanging around for a while, you should release the autorelease pool periodically and create a new one. The same goes for long running loops.

- Chris



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Releasing Objects Allocated in Different Autorelease Pool (From: Eric Blanpied <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.