Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Does [NSApp setApplicationIconImage] leak memory?



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.