Re: NSAutoreleasePool causes crashes when empty?
Re: NSAutoreleasePool causes crashes when empty?
- Subject: Re: NSAutoreleasePool causes crashes when empty?
- From: "Kevin Dixon" <email@hidden>
- Date: Thu, 3 Apr 2008 22:05:14 -0400 (EDT)
- Importance: Normal
Here's the contents of my thread's routine
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
mEngine->Destretch(mAudioFileList, [uiOutputDirectory stringValue],
smpteIndex);
[pool release];
[NSThread exit];
}
In ->Destretch the only real allocation of Cocoa stuff is this
NSURL * url = [NSURL fileURLWithPath: filePath];
CFURLGetFSRef((CFURLRef)url, &output);
Does this need to be CFReleased some how?
Its not very exciting, though since its objective-c++, maybe that's a
factor. The stack trace looks like this:
0 objc_msgSend
1 ??
2 -[SFWindowController destretchWorkerThreadEntryPoint:]
3 forkTheadForFunction
4 _pthread_body
when I click on 2, it highlights the [pool release] line.
Any ideas? I'm a little lost
-Kevin
> I'd suspect some sort of error in your app, e.g. perhaps "pool" itself
> has never been alloc/inited and contains garbage. [pool release] on a
> valid but empty NSAutoreleasePool is perfectly harmless.
>
> Kevin Dixon wrote:
>> I have a method in my class that's a thread entry point, using
>> detachNewThreadSelector. According to the docs, I create an
>> NSAutoreleasePool and release it at the end of the thread's life (right
>> before [NSThread exit].
>>
>> The thread calls a single routine from another class. Sometimes this
>> routine aborts before allocating any objects that would be autoreleased
>> (due to an error situation). I notice when this is the case, calling
>> [pool
>> release] causes a crash, but if the objects are allocated normally due
>> to
>> the full run of the function, then no crash occurs.
>>
>> Is there a way I can query the pool to see if it needs to be released,
>> or
>> should I implement some sort of return code from my other function to
>> see
>> if I should release the pool or not.
>>
>> Thanks,
>>
>> -Kevin
>> _______________________________________________
>>
>> 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
>>
>
_______________________________________________
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