Re: NSTimer never being deallocated
Re: NSTimer never being deallocated
- Subject: Re: NSTimer never being deallocated
- From: Tobias Jordan <email@hidden>
- Date: Sat, 13 Mar 2010 17:41:50 +0100
Hi Mani,
Thanks a lot, sounds good although I am not really happy with the fact
that Apple doesn't mention it somewhere. I know a lot of developers
who don't care about Instruments and memory leaks'n'stuff that's why
their software will be always buggy.
I want to know what's going on inside my app and I've got enough
experience in coding to know that just trusting the Apple docs
(especially when it's about memory management) is not reliable.
Best regards,
Tobias Jordan.
On Mar 13, 2010, at 4:56 PM, Manfred Schwind wrote:
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 (email@hidden)
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:
This email sent to email@hidden