Re: CIImage drawAtPoint: ...... retains image??
Re: CIImage drawAtPoint: ...... retains image??
- Subject: Re: CIImage drawAtPoint: ...... retains image??
- From: Nik Youdale <email@hidden>
- Date: Sat, 15 Dec 2007 18:36:03 +1100
I see - thanks for the explanation on retain count - it makes sense.
I'm using 'Instruments' (previously known as XRay - why did they
change the name?....) with the object alloc tool, and it appears that
most memory is being used by QuartzCore in a massive tree of calls
going something like "fe_tree_create_texture > fe_texture_new >
texture_retain > blah blah blah".
Disabling the drawAtPoint: call clears up the memory leaks.
So it appears that its a whole bunch of functions within QuartzCore
and CoreGraphics causing the issue - of course appearances can be
deceiving.
What is the best way to be certain that I'm releasing drawImage
properly? I've looked through the code and made sure every retain is
balanced by a release, so i'm fairly certain that it is being released.
Thanks,
Nik
On 15/12/2007, at 6:19 PM, Andrew Farmer wrote:
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