Re: NSImages are killing my WindowServer
Re: NSImages are killing my WindowServer
- Subject: Re: NSImages are killing my WindowServer
- From: Troy Stephens <email@hidden>
- Date: Thu, 23 Mar 2006 11:22:23 -0800
On Mar 23, 2006, at 10:35 AM, James Bucanek wrote:
John Stiles wrote on Thursday, March 23, 2006:
See if your idea of releasing them sooner helps.
You could also use ObjectAlloc to see just how many NSImages you're
making... it may be more than you expected!
I think you're right about the number. Looking at the code again, I
think it could approach a thousand or more at a time.
Anytime you let autoreleased objects pile up, you're deferring
reclamation of the resources they own (memory, and in this case
offscreen windows as well) until they objects are finally
deallocated. It sounds as if in this case your code would benefit
from setting up a local (aka "nested") autorelease pool in an
appropriate place (e.g. just inside the loop where you iterate over
your N images to be processed).
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/
Concepts/AutoreleasePools.html
This would enable you to continue using the convenient ownership
semantics of the autorelease mechanism, while scoping your
autoreleased objects' lifetimes more tightly so that they get cleaned
up when they're no longer needed (e.g. at the end of each iteration).
My concern is in reusing NSImage. What do I have to do to "reset"
an NSImage so I can draw another IconRef into it? Right now, the
NSImage that gets drawn and converted into a TIFF has all of the
yummy transparency information and all of that other chocolately
Cocoa goodness. I'm afraid if I start drawing multiple icons over
each other that I'm going to have problems.
Filling the image with [NSColor clearColor] is sufficient to erase
its contents.
--
Troy Stephens
Cocoa Frameworks
Apple
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden