• 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: "Kyle Sluder" <email@hidden>
  • Date: Mon, 11 Aug 2008 01:19:49 -0400

On Sun, Aug 10, 2008 at 8:04 PM, Matt Neuburg <email@hidden> wrote:
> That's perhaps perfectly true. But "later" could be a LOT later - and in the
> meantime quite a lot of memory could pile up. For example, it is the nature
> of the Cocoa event loop that the autorelease pool gets cleaned out when the
> user switches to another app and back to your app. But that might not happen
> for quite some time.

I was under the impression that Cocoa flushed the top autorelease pool
at the top of the runloop.  But this is an Implementation Detail,
after all.

> To cite an example in my own life, in an app where I
> was creating a lot of autoreleased strings as I gathered data from a huge
> MySQL database, I actually caused my computer to freeze up for lack of
> memory. When I created my own autorelease pool and released it every n times
> thru the loop, the problem went away. This is, indeed, an *extremely* common
> technique for doing exactly what you say - making it happen "now".

Believe me, I'm very familiar with this technique.  I have an app that
draws a lot of little rounded rectangles, and it's important that I
don't just create a ton of autoreleased NSBezierPaths, but instead
explicitly alloc and release them.  Otherwise my working set grows
dramatically.

> So, to resume, it may in fact be that the OP's app is NOT truly "leaking" -
> but rather, that exactly what I'm describing here is what's happening to
> him: the built-in autorelease pool is just piling up and not getting
> released, because the event loop hasn't exited yet. The fact that the
> problem he is seeing does in fact go away for him when he does what I
> suggested is an indication that it is. This is one of the possible
> conclusions towards which, in my Socratic little way, I'm trying to lead the
> OP. Stay tuned. m.

Or maybe it has something to do with him explicitly retaining the
autoreleased NSArrays he's creating, and inappropriately using usleep
instead of an NSTimer...

--Kyle Sluder
_______________________________________________

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: "Kyle Sluder" <email@hidden>)
 >Re: Does [NSApp setApplicationIconImage] leak memory? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Why use NSObjectController?
  • Next by Date: Re: Get specified window from nib
  • Previous by thread: Re: Does [NSApp setApplicationIconImage] leak memory?
  • Next by thread: Re: Does [NSApp setApplicationIconImage] leak memory?
  • Index(es):
    • Date
    • Thread