Leaking images
Leaking images
- Subject: Leaking images
- From: John Timmer <email@hidden>
- Date: Thu, 20 Feb 2003 23:07:58 -0500
Greetings -
I've got a program on an NSTimer that repeats every 5 minutes or so between
checking something and (potentially) grabbing an image from a server. If I
set it up so it repeats quickly and always grabs the image, it's clear it's
leaking memory. Using "leaks" indicates that a lot of it is in the form of
NSImages. I've tried a bunch of variations on the following code, but
either I leak or I tank because I try to release something that no longer
exists. Any advice is appreciated.
NSData *imageData = [[[ NSData alloc] initWithContentsOfURL: theURL
]autorelease];
NSImage *tempImage = [[NSImage alloc] initWith
Data:imageData];
// this bit simply prevents the background from blowing holes in
wherever it's composited
[weatherImage release];
weatherImage = [[[NSImage alloc] initWithSize:[tempImage size]] retain];
[weatherImage lockFocus];
[tempImage compositeToPoint:NSMakePoint(0,
0)operation:NSCompositeSourceOver];
[weatherImage unlockFocus];
[tempImage release];
I do the compositing in a different method, but I don't create any images
there.
By the way, I'm leaking something else, too - in some archives, I've seen
that NSURL leaks - is this still the case, or should I look elsewhere?
Cheers,
John
_______________________________________________
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.