NSImage leaks on every draw?! Help!
NSImage leaks on every draw?! Help!
- Subject: NSImage leaks on every draw?! Help!
- From: "Ben Kennedy" <email@hidden>
- Date: Thu, 24 Oct 2002 15:50:36 -0400
- Organization: Zygoat Creative Technical Services
Hi all,
Here's something that I've just horrendously discovered, which I can't
explain.
I have an NSImage, img, which I am rendering in a workhorse method called
from my custom view's drawRect: method, like so:
[img drawInRect:r1 fromRect:r2 operation:NSCompositeSourceOver
fraction:1.0];
The problem is, every time executing that line, the app allocates several
hundred KB of memory and never releases it. I see this by watching VSIZE
(running "top") constantly increase.
For kicks, I have wrapped that line in a 20x for-loop to exacerbate the
problem; indeed, it leaks 20x as much memory every time. I've
encapsulated the line with NSAutoreleasePool *pool = [[NSAutoreleasePool
alloc] init]; ... [pool release]; the results are no different.
Now, you're going to wonder where the image comes from in the first
place. It's stored in my document as an archived object, brought to life
in initWithCoder:, and initially supplied by the user from any source
(PDF, GIF, etc).
Interestingly, the leaks do not occur if I hard-code a particular pre-
existing image with a line such as img = [NSImage imageNamed:@"foo"].
They do under normal use though, where the NSImage comes from the
unarchived document.
Can somebody help here; wtf is going on?
thanks,
-ben
--
Ben Kennedy, chief magician
zygoat creative technical services
613-228-3392 | 1-866-466-4628
http://www.zygoat.ca
_______________________________________________
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.