Re: CIImage drawAtPoint: ...... retains image??
Re: CIImage drawAtPoint: ...... retains image??
- Subject: Re: CIImage drawAtPoint: ...... retains image??
- From: Andrew Farmer <email@hidden>
- Date: Fri, 14 Dec 2007 23:19:39 -0800
On 14 Dec 07, at 23:10, Nik Youdale wrote:
I'm trying to draw a CIImage in a view, but have come across the
following problem:
CIImage *drawImage;
.......
NSLog(@"draw image retain count: %d", [drawImage retainCount]);
[drawImage drawAtPoint:drawPoint fromRect:drawRect
operation:NSCompositeSourceOver fraction:1.0];
NSLog(@"draw image retain count: %d", [drawImage retainCount]);
NSLog output:
draw image retain count: 1
draw image retain count: 2
after the drawing operation, the retain count of the image is 1
greater than before the drawing call. From what I understand about
memory management... that shouldn't happen?? This is causing massive
leaks in my program.
Short version: retainCount is a false idol. Don't worship it.
Longer version: Some AppKit routines might be temporarily retaining
objects "behind your back". For example, I wouldn't be surprised if
drawAtPoint were temporarily retaining the image until you finish
drawing. This shouldn't affect your application's overall memory
mangement, although it will make retainCount do unexpected things. The
immediate solution is simply to not look at retainCount, as features
such as autorelease will make it deliver results that aren't
particularly meaningful.
On to more permanent solutions - have you actually run MallocDebug or
any other tools to actually look at where memory is going? In
particular, are you sure you're appropriately managing the lifecycle
of drawImage?
_______________________________________________
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