Re: Monster memory leak and I can't figure out why
Re: Monster memory leak and I can't figure out why
- Subject: Re: Monster memory leak and I can't figure out why
- From: Jens Alfke <email@hidden>
- Date: Tue, 1 Jun 2010 11:22:14 -0700
On May 31, 2010, at 6:41 PM, Ken Tozier wrote:
> What's happening is that if I comment out the line that initializes a new image, the memory leak disappears. I've tried forcibly releasing the images, tried autoreleasing them, tried creating a fixed size buffer into which all the images are read, nothing seems to work.
First off, -retain / -release / -autorelease are all no-ops when GC is enabled, so calling them won’t make any difference.
NSImage does some caching behind the scenes, by default, and this might not be getting cleaned up in a timely enough manner. You could try using the caching-related NSImage methods to try to reduce this.
(A common issue in GC environments is that the collector isn’t aware of large external memory buffers that aren’t in the GC heap but are kept around by GC’d objects. So in this case the collector may not realize that, although the NSImage objects themselves are small, they’re holding onto large pixmap buffers in the malloc heap. So it probably isn’t running frequent enough collections to free up that memory.)
Another option is to directly tell the collector to run a collection after every pass through your loop.
—Jens_______________________________________________
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