Re: Why does this leak memory?
Re: Why does this leak memory?
- Subject: Re: Why does this leak memory?
- From: Jamie Curmi <email@hidden>
- Date: Sun, 19 Jan 2003 12:04:01 +1100
This is a good idea, and one that I toyed with. But if the image under
the numbers is complicated, not a solid colour, then this is much more
difficult. You need to somehow fill in the drawn in to part with the
original image - hence the use of copy.
I played around with NSImage's initWithContentsOfFile: and this also
has the same problem. Ie, if you create a new image with alloc and
init, you can release that and there is no leak. However, if you
initialise it with initWithContentsOfFile:, you have the same sort of
leak as before. So the leak seems to be in either getting the image,
or copying the contents of that image in to the new image.
I thought that possibly NSImage caches each copy, and that cache is the
cause of the leak. But all the NSImage methods for controlling caching
seem to make no difference.
Jamie
On Sunday, January 19, 2003, at 11:46 AM, j o a r wrote:
Just another idea - why don't you keep just one image for this
purpose. When you need to modify the counter you could simply use the
old image and paint over the old numerical value with your background
color and then draw the new updated numbers in place - no need to
create a new copy every time.
j o a r
On Saturday, Jan 18, 2003, at 23:27 Europe/Stockholm, Jamie Curmi
wrote:
I'll try and explain what I am trying to do. My application has a
dock icon that is updated to reflect status in the application (it
has a graphical count amongst other things).
What I originally was doing was to just retain the image as you
suggested. However, I then modify that image by adding a count to it
graphically. Then I set the application icon ([NSApp
setApplicationIconImage:icon];).
Trouble is that next time I call [NSImage imageNamed:@"Connected"] I
have the modifications as well, so numbers get drawn on top of
numbers, and that messes up the icon.
So I decided what I really needed to do was make a copy of the
[NSImage imageNamed:@"Connected"]. Then I modify that. I set the
application icon image. And release the copy.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.