Re: Background app + NSTimer
Re: Background app + NSTimer
- Subject: Re: Background app + NSTimer
- From: Chris Kane <email@hidden>
- Date: Fri, 4 Jan 2002 18:00:11 -0800
On Thursday, January 3, 2002, at 05:06 AM, Raphael Sebbe wrote:
As the subject says, I have a Cocoa (AppKit) app in the background that
regularly reschedules timers in its run loop. Checking the ObjectAlloc
output, I saw the timer's target was not released after the timer was
invalidated unless I brought the app in the foreground (all targets get
correctly deallocated at that time). This is quite annoying to me since
that app is of the kind that always stays in the background.
Perhaps I did not look long enough to see those targets deallocated, or
there are some runloop tweaking possible. Could someone comment on
this ?
Perhaps something is releasing the target, but doing that via
autorelease, and the target is stuck in the AppKit's event loop
autorelease pool until you bring the app front (or, if it were already
front, giving any event to it). Or similarly, something else (the
timer?) has retained the target, and it got autoreleased (as via the
NSTimer class creation methods) and the autorelease pool it ended up in
is not being freed because execution is not continuing to that point.
These possibilities can be investigated in ObjectAlloc by looking at the
event sequences in the instance browser (middle tab), or by using the
Find panel with pointer values, and examining the backtraces (mostly,
for depth). There's no way to tell of course where the autorelease
pools are stacked in a backtrace in ObjectAlloc. But if you find the
eventual release of the target when you do bring the app front, you can
see how deep that is, and where it is, to know where the pool was.
Chris Kane
Cocoa Frameworks, Apple