On Mar 8, 2010, at 10:44 PM, Philippe Sismondi wrote:

> In other words, the MadeObj instance for AppController's instance variable is 
> created and then immediately dealloc'd. I take this to mean that the 
> autorelease pool it was in was released/drained. If I change the 
> AppController init method to retain instanceMadeObj, the dealloc does not 
> happen.

Correct.

> I don't understand this. When is the autorelease pool created/released? I 
> would guess that the AppController instance is created outside the main event 
> loop. If the answer is in the Memory Management Programming Guide, it is not 
> obvious to me. I did not expect that I should autorelease the instance 
> variable in this case.

Read the Cocoa Fundamentals Guide:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW39

From the section "How Memory Management Works":

"If you are developing an application you may not need to set up an autorelease 
pool; the Application Kit automatically sets up an autorelease pool scoped to 
the application’s event cycle."

This explains the behavior you're seeing: every time your application goes 
through its event cycle, the main autorelease pool is drained.

Hope this helps,
Hank

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to