On Apr 8, 2010, at 10:36 AM, Patrick M. Rutkowski wrote:

> Is it common in either Cocoa or UIKit to have an autorelease run
> happen only when the user does something?

> I'm in a situation where I believe the autorelease run is happening
> only when I push a bush or otherwise fiddled with a UI item; might
> that be the case, or am I confused?

I think you may be confused here. There's no such thing as an 'autorelease 
run'. Autoreleased objects are collected in autorelease pools. The main 
autorelease pool in an application with a UI is drained every so often (every 
time the application goes through its main event loop).

You shouldn't have to worry about when autoreleased objects get released: the 
only thing you need to know is whether or not you're responsible for the 
release of an object. This is explained at length in the Memory Management 
Programming Guide:

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/MemoryMgmt/MemoryMgmt.html

Also, check the documentation for NSAutoreleasePool.

Hope this helps,
Hank

> 
> -Patrick
> 
> P.S.
> Is there perhaps a way to have it logged to the console whenever an
> autorelease run happens?

I'm assuming you're referring to the draining of an autorelease pool again. 
Since the main autorelease pool is drained at the end of the event loop, I 
guess you could attach an observer to the main run loop (search the docs for 
runloop observer), but there may be better ways. Why would you want to know 
this?

> _______________________________________________
> 
> 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/hank.list%40runbox.com
> 
> This email sent to hank.l...@runbox.com
> 

_______________________________________________

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