• 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: NSImage allocation issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage allocation issues


  • Subject: Re: NSImage allocation issues
  • From: Clark Cox <email@hidden>
  • Date: Fri, 30 Apr 2004 08:16:54 -0400

On Apr 30, 2004, at 07:41, Jesus De Meyer wrote:

> Hi,
>
> I just found a big memory leak in my application. Let me explain. I use
> a menu that shows small icons and one of its submenus receives the icon
> from files (via NSWorkspace). Now I've seen that in my iteration
> process the images remain allocated. I have tried sending them the
> autorelease message but that didn't work, it made my app crash.
>
> This is what I currently do:
>
> NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle:theItem action:nil
> keyEquivalent:@""];
> NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:itemPath];
>
> if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"showIcons"]
> intValue] && icon) {
> [icon setSize:NSMakeSize(16, 16)];
> [mi setImage:icon];
> }
> [menu addItem:mi];
>
> Anybody know how I can fix this?

I don't see the problem. The image is retained by the menu item.


--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: NSImage allocation issues
      • From: Nicko van Someren <email@hidden>
    • Re: NSImage allocation issues
      • From: Jesus De Meyer <email@hidden>
References: 
 >NSImage allocation issues (From: Jesus De Meyer <email@hidden>)

  • Prev by Date: NSImage allocation issues
  • Next by Date: Re: NSImage allocation issues
  • Previous by thread: NSImage allocation issues
  • Next by thread: Re: NSImage allocation issues
  • Index(es):
    • Date
    • Thread