• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Does [NSApp setApplicationIconImage] leak memory?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does [NSApp setApplicationIconImage] leak memory?


  • Subject: Re: Does [NSApp setApplicationIconImage] leak memory?
  • From: Mark Allan <email@hidden>
  • Date: Fri, 8 Aug 2008 23:53:08 +0100

On Fri, Aug 8, 2008 at 9:02 AM, Matt Neuburg <email@hidden> wrote:
 On Thu, 7 Aug 2008 20:14:04 +0100, Mark Allan <email@hidden>
 said:
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.

Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this:

        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        [NSApp setApplicationIconImage: whatever];
        [pool release];

 I think you'll find that solves the problem.

> m.
At 6:24 pm -0400 08/08/2008, Sumner Trammell wrote:
Ok, stupid question time.

1. Is the need for the autorelease pool because of the use of
setApplicationIconImage, or because of the array that is being used in
conjunction with setApplicationIconImage?

2. Would putting the calls to setApplicationIconImage in a class
method also stop the memory leak?

Thanks,

-s

Certainly not a stupid question, in fact, now *I* feel stupid for not trying that first suggestion earlier. Your idea of removing the array from the equation also solves the leak and I suspect is more efficient than creating and releasing a tonne of autorelease pools.


Thanks guys.

M

_______________________________________________

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


References: 
 >Re: Does [NSApp setApplicationIconImage] leak memory? (From: Matt Neuburg <email@hidden>)
 >Re: Does [NSApp setApplicationIconImage] leak memory? (From: "Sumner Trammell" <email@hidden>)

  • Prev by Date: Re: Does [NSApp setApplicationIconImage] leak memory?
  • Next by Date: Re: How to tell whether an executable supports GC?
  • Previous by thread: Re: Does [NSApp setApplicationIconImage] leak memory?
  • Next by thread: Re: Does [NSApp setApplicationIconImage] leak memory?
  • Index(es):
    • Date
    • Thread