Re: CALayer contents memory leak
Re: CALayer contents memory leak
- Subject: Re: CALayer contents memory leak
- From: David Duncan <email@hidden>
- Date: Tue, 4 Nov 2008 09:05:14 -0800
On Nov 2, 2008, at 9:08 PM, Adam Fedor wrote:
image = [[NSImage alloc] initWithContentsOfFile: next];
if (image)
{
CGImageRef imageRef = NULL;
CGImageSourceRef sourceRef;
sourceRef = CGImageSourceCreateWithData((CFDataRef)[image
TIFFRepresentation], NULL);
if(sourceRef) {
imageRef = CGImageSourceCreateImageAtIndex(sourceRef, 0, NULL);
CFRelease(sourceRef);
}
[rootLayer setContents: (id)imageRef];
CGImageRelease(imageRef);
}
[image release];
While I don't see a leak in here, it can never hurt to simplify your
code. Try this instead.
NSURL *url = [NSURL fileURLWithPath:next isDirectory:NO];
if(url != NULL)
{
CGImageRef imageRef = NULL;
CGImageSourceRef sourceRef = CGImageSourceCreateWithURL((CFURLRef),
NULL);
if(imgSrc != NULL)
{
imageRef = CGImageSourceCreateImageAtIndex(sourceRef, 0, NULL);
CFRelease(sourceRef);
}
[rootLayer setContents: (id)imageRef];
CGImageRelease(imageRef);
}
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
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