Re: NSImage release crash
Re: NSImage release crash
- Subject: Re: NSImage release crash
- From: "M. Uli Kusterer" <email@hidden>
- Date: Fri, 5 Nov 2004 00:29:39 +0100
At 14:21 Uhr -0800 01.11.2004, Paul Collins wrote:
NSImage *theImage = nil;
NS_DURING
theImage = [[NSImage alloc]
initWithContentsOfFile:[aSlide cachePath]]; // can raise exception
(...) NS_ENDHANDLER
// retain the image in my custom object.
[slide setThumbImage: theImage];
(...)
[theImage release];
(...)
This code is called within a CFNetwork callback (it's just
downloaded the original image). Would that be a problem? I could run
it from an NSTimer after the callback if that's better.
Most of AppKit is not thread-safe, so if CFNetwork runs in a
separate thread (which many network libs do), this may be a good
candidate for your problem. The docs on NSImage will say if it's
thread-safe. If they don't, it very likely isn't.
Another candidate for the crash could be your setThumbImage: call.
If your model class isn't thread-safe or fails to retain any objects
it keeps in its member variables, that could be your problem. In
particular, are you sure "slide" still exists at the point you set
it? There's no chance the main thread could have disposed of it?
This bug appears to have been introduced while fixing other bugs -
the major other fix was adding several NSAutoreleasePools to ensure
timely releases, although these are not involved this this object.
Any suggestions on how to avoid or at least diagnose this bug?
There were a couple of links to tools for debugging memory leaks
etc. posted to this list a while back.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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