> I sent an -invalidate to my instance of NSTimer in -fire: but Instruments 
> told me the object was still alive. This is really confusing, I think the 
> instance should be released when sending an invalidate so mem-management is 
> clean and fine as it is in every other Apple ObjC class.

This is just some optimization in the internal Cocoa implementation. I recently 
found out that Cocoa just reuses NSTimer instances:
If you create an NSTimer object with scheduledTimerWithTimeInterval and then 
are done with it and your releases are just fine, the NSTimer instance may NOT 
get freed. But if you get another NSTimer instance with 
scheduledTimerWithTimeInterval, you'll find out that you often get the same 
NSTimer instance again. Cocoa is just caching NSTimer instances internally for 
re-use.
But all this is just implementation detail that you don't have to worry about. 
Just make sure to follow the memory guidelines and all is fine. Sending an 
additional release is wrong and will crash, of course.

Regards,
Mani
--
http://mani.de - friendly software
iVolume - listen to music hands-free
LittleSecrets - the encrypted notepad
Sahara - sand in your pocket
Watchdog - baffle the curious

_______________________________________________

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