Does [NSApp setApplicationIconImage] leak memory?
Does [NSApp setApplicationIconImage] leak memory?
- Subject: Does [NSApp setApplicationIconImage] leak memory?
- From: Mark Allan <email@hidden>
- Date: Thu, 7 Aug 2008 20:14:04 +0100
Hi all,
Before I file a bug report against this, I just thought I'd check I'm
not being monumentally stupid first!
I'm trying to animate my app's Dock icon, which works fine and looks
great, but unfortunately, it appears to leak memory like crazy.
Every time I call [NSApp setApplicationIconImage:(NSImage *)] and
pass it pointer to an existing image, it leaks more memory.
My init method sets up 8 frames of the animation like so:
frame1 = [[NSArray arrayWithObjects: [NSImage
imageNamed:@"menu_frame1"], [NSImage imageNamed:@"dock_frame1"], nil]
retain];
frame2 = [[NSArray arrayWithObjects: [NSImage
imageNamed:@"menu_frame2"], [NSImage imageNamed:@"dock_frame2"], nil]
retain];
and so on...
I'm using an NSArray there as I may alternatively need to animate a
menubar icon depending on the user's preferences, and the images have
different dimensions accordingly.
The method which does the drawing looks like this:
- (void) setMenuAndDockTile:(NSArray *)theNewImage {
[NSApp setApplicationIconImage:[theNewImage objectAtIndex:1]];
}
and it gets called in a loop containing something like this:
[self setMenuAndDockTile:frame1];
usleep(100000);
[self setMenuAndDockTile:frame2];
usleep(100000);
<...and so on for 8 frames...>
Each frame is only a fraction over 1KB, yet after 5 times round the
loop (ie changing the Dock tile 40 times) it has managed to eat 27 MB
and the memory usage increases every time I tell it to animate.
Am I doing something wrong, or is there a leak in NSApp's
setApplicationIconImage code?
Many thanks
PS. I can post the full source and images if that would help.
_______________________________________________
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