Re: NSTimer never being deallocated

2010-03-14 Thread Tobias Jordan
If these cachings don't result in a huge memory leak (which they obviously don't do) I am fine with it. :-) On Mar 14, 2010, at 10:09 PM, Steve Christensen wrote: On Mar 13, 2010, at 10:57 AM, Tobias Jordan wrote: What made me think it is a bug was actually only the fact that instruments t

Re: NSTimer never being deallocated

2010-03-14 Thread Steve Christensen
On Mar 13, 2010, at 10:57 AM, Tobias Jordan wrote: What made me think it is a bug was actually only the fact that instruments told me the object is always still alive and the 'missing' note in the documentations that tell me I don't need to release it because of some caching techniques. W

Re: NSTimer never being deallocated

2010-03-14 Thread Jeremy Pereira
On 13 Mar 2010, at 23:56, Tobias Jordan wrote: > Hi Paul, > > You said 'an object you don't manage' -- If I alloc/init an instance of > NSTimer I am responsible for this object, in my opinion. Until you release it. After that, you are not responsible for it. That doesn't mean that something

Re: NSTimer never being deallocated

2010-03-13 Thread Tobias Jordan
Hi Paul, You said 'an object you don't manage' -- If I alloc/init an instance of NSTimer I am responsible for this object, in my opinion. That's why I tried to do everything properly. You see I am actually really just trying to prevent memory leaks and I see lots of leaks in sample code I a

Re: NSTimer never being deallocated

2010-03-13 Thread Paul Sanders
I don't understand all the confusion on this issue. The NSTimer documentation makes the life-cycle of this object very clear. Until it goes away, it is probably retained by the runloop. As Joar says, you often can't make any concrete predictions about when an object you don't manage yourself m

Re: NSTimer never being deallocated

2010-03-13 Thread Gordon Apple
I haven't followed this whole thread, but my experience is that an NSTimer (especially a repetitive one) is an easy thing to leak, even in a GC environment (which I use). To prevent it, you have to make sure you keep a reference to the timer so that you can actually invalidate it, taking it out of

Re: NSTimer never being deallocated

2010-03-13 Thread Tobias Jordan
Hi Joar, Thanks a lot for taking the time to respond to this request! Let me explain what made me write to this cocoa list and think NSTimer's got a memory leak: When reading through all the class documentations from Apple I often see some notes in the discussion group that say something

Re: NSTimer never being deallocated

2010-03-13 Thread Paul Sanders
For the benefit of the OP, according to the docs (and this fits in with my own experience), calling [NSTimer invalidate] will release the timer at some future point in the run loop and is in fact the only way to get rid of it. So there is really nothing to worrry about. Trust in Papa Cocoa, al

Re: NSTimer never being deallocated

2010-03-13 Thread Dave Keck
>> Recycled objects can appear as leaks, making it hard to distinguish >> between a bug and normal behavior. > > I don't think that's true (it doesn't fit with the algorithm used for > identifying leaks), but if it is, please file a bug report: I didn't mean to imply the Leaks instrument. Using t

Re: NSTimer never being deallocated

2010-03-13 Thread Joar Wingfors
On 13 mar 2010, at 09.08, Tobias Jordan wrote: > Yes, don't get me wrong, I trust the Apple docs, of course but I also know > it's possible they are doing something wrong. I don't remember all cases but > it always starts like this: I see something's not being freed, I try to free > it, it doe

Re: NSTimer never being deallocated

2010-03-13 Thread Joar Wingfors
of > NSTimer and I thought like why is the NSTimer never being deallocated?? OKay > so I created a demo NSTimer memory app and started testing with Instruments > (Object Allocations Tool). In my opinion, there's a serious memory leak here > since it's impossible to relea

Re: NSTimer never being deallocated

2010-03-13 Thread Tobias Jordan
Yes, don't get me wrong, I trust the Apple docs, of course but I also know it's possible they are doing something wrong. I don't remember all cases but it always starts like this: I see something's not being freed, I try to free it, it doesn't work, I do a search on it and notice there are

Re: NSTimer never being deallocated

2010-03-13 Thread Joar Wingfors
On 13 mar 2010, at 08.57, Dave Keck wrote: > Recycled objects can appear as leaks, making it hard to distinguish > between a bug and normal behavior. I don't think that's true (it doesn't fit with the algorithm used for identifying leaks), but if it is, please file a bug report:

Re: NSTimer never being deallocated

2010-03-13 Thread Dave Keck
> Please explain this. > > If you stick to the memory rules you’re fine. Recycled objects can appear as leaks, making it hard to distinguish between a bug and normal behavior. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post ad

Re: NSTimer never being deallocated

2010-03-13 Thread Alexander Spohr
Am 13.03.2010 um 17:41 schrieb Tobias Jordan: > 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. Please explain this. If you stick to the memory r

Re: NSTimer never being deallocated

2010-03-13 Thread Tobias Jordan
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

Re: NSTimer never being deallocated

2010-03-13 Thread Manfred Schwind
> 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 i

NSTimer never being deallocated

2010-03-13 Thread Tobias Jordan
Hey Devs, I've always been having problems with Foundation's NSTimer Class when it comes to Memory-Management. After activating the static analyzer in Xcode (very useful!), it immediately reminds me of autoreleasing my instance of NSTimer and I thought like why is the NSTimer n