Re: Modal loop memory leak on 10.6
Re: Modal loop memory leak on 10.6
- Subject: Re: Modal loop memory leak on 10.6
- From: Jo Meder <email@hidden>
- Date: Tue, 21 Dec 2010 14:33:17 +1300
Hi Fritz,
On 21/12/2010, at 5:07 AM, Fritz Anderson wrote:
> We don't have your code (and there may be a lot of it before we can find the bug), so I'm just going on brute instinct…
>
> Are you doing anything other than strict, narrow, swear-on-your-mother's-life-it's-only, drawing in drawRect:? Are you changing model state? Calling back to a controller action? Are you trying to trigger redraws?
I went through and commented out calls from drawRect: into my own code, so I'm not doing anything when drawRect: is called. I've also commented out all calls to setNeedsDisplay: and setNeedsDisplayInRect:. A lot of the drawing (OpenGL) in the app is triggered by timers so I've prevented the timers starting. The timers weren't firing anyway as they're not on the modal event loop, but just to be certain. I've commented out the few places I was adding observers directly. All to no avail, the leak is still happening.
I use Cocoa at fairly basic level because the Cocoa stuff is the back end to a C++ GUI framework. I'm not doing anything particularly fancy, such as KVO.
Here's how I run the modal loop just in case:
NSWindow* macWindow = ( NSWindow* )theDialog.GetNativeWindow();
UCMacWindowImp* windowImp = ( UCMacWindowImp* )theDialog.GetImplementation();
if ( ( macWindow != nil ) && ( windowImp != NULL ) )
{
NSModalSession modalSession;
// Need to retain then release window because [NSApp endModalSession] seems to expect
// the window to still be around on 10.4 and 10.5
[macWindow retain];
modalSession = [NSApp beginModalSessionForWindow:macWindow];
windowImp->SetModalSession( modalSession );
for (;;)
{
if ([NSApp runModalSession:modalSession] != NSRunContinuesResponse)
break;
}
[NSApp endModalSession:modalSession];
[macWindow release];
}
Thanks for your help.
Regards,
Jo Meder
_______________________________________________
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