cfischer
cfischer

Reputation: 24912

Autorelease pools in appkit applications

I'm having difficulties to understand exactly WHEN autorelease pools are created and released in AppKit apps.

For example, if I have an ApplicationController class that overrides init, is there an autorelease pool that gets created before it starts and gets drained after it ends?

Upvotes: 0

Views: 306

Answers (1)

Lily Ballard
Lily Ballard

Reputation: 185751

The main thread in an AppKit application runs an NSRunLoop to process events. NSRunLoop creates a new autorelease pool every time it processes a new event (or timer) and drains it once control flow has returned to the NSRunLoop. So in essence, every pass through the run loop has a fresh autorelease pool.

Upvotes: 1

Related Questions