Thanks
Thanks

Reputation: 40339

Where are all the pre-installed autorelease pools in iPhone applications?

I am wondering how many there are, and where they are. As I have seen in a Stanford Vid, there is one autorelease pool installed in the event loop of an iPhone App. But I think I missed the point where exactly that is? And are there any other autorelease pools that I should know about?

Upvotes: 0

Views: 219

Answers (3)

Marco
Marco

Reputation: 15027

Every thread that you create needs its own autorelease pool. Check the documentation for NSThread for details.

Your main application thread, by default, will use the one created in main.m. Unless you're doing a bunch of big operations like Marc Charbonneau said, you generally don't need to create others. And if you're really doing that many operations, it might be a good idea to do them in a separate thread anyway.

Upvotes: 2

Marc Charbonneau
Marc Charbonneau

Reputation: 40515

The application's autorelease pool drains every pass through the run loop. You can add your own pool anywhere you want, if you have a big loop that creates a lot of objects it can be a good idea to put a pool there to limit memory usage.

Upvotes: 2

oxigen
oxigen

Reputation: 6263

in main.m file (in X-code it is in "Other Sources" folder)

Upvotes: 4

Related Questions