Re: NSImages are killing my WindowServer
Re: NSImages are killing my WindowServer
- Subject: Re: NSImages are killing my WindowServer
- From: John Stiles <email@hidden>
- Date: Thu, 23 Mar 2006 10:40:08 -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.
Ricky Sharp wrote on Thursday, March 23, 2006:
Something I always code up when working with many images is an
"ImageFactory".
While the contents of NSImages are cached, I find it helpful to
provide a
helping hand. My factory often implements it's own cache of a
fixed size
where I implement a 'most-recently-used' policy. This allows me
to easily
play around with the cache size to experiment with memory
consumption vs.
speed.
Thanks to both John and Ricky for the suggestions.
Looking at the structure of my code, I think it might be easier to
create a cache. All of the code that calls this function expects an
autoreleased NSImage, and I'd have to return a retained one if I
want the clients to release it immediately.
The client code couldn't just wrap it with a new NSAutoreleasePool?
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.
Maybe something along these lines:
[[NSColor clearColor] set];
NSRectFill( ... your image's frame ... );
_______________________________________________
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