Does each thread need its own pool of abstracts?

Does each thread have its own pool? I am writing an iPhone application that uses streams. If I don’t pool the thread, he complains about a leak.

What I wanted to do was store some object that is experiencing the stream. How can i do this?

+4
source share
3 answers

No, everyone NSThreadhas his own NSRunLoop, but not his own NSAutoreleasePool. So you have to create it, and if you are doing a large operation or operation that takes a lot of time, you should use the drainpool from time to time to keep the memory low.

, , , , , , . , .

+7

, JustSid: autorelease, autoreleasepool, . , , , .

: , autoreleasepool !

+3

If you do not need the runloop associated with your thread, you need to create an autoplay pool manually. I would suggest that to transfer ownership of an object to another thread, you make it explicit rather than trying to rely on autorelease; have a kind of “take ownership” method, called a longer stream, which preserves it.

+1
source

All Articles