Re: Nested AutoRelease Pools Crash
Re: Nested AutoRelease Pools Crash
- Subject: Re: Nested AutoRelease Pools Crash
- From: Trygve Inda <email@hidden>
- Date: Sun, 26 Apr 2009 17:41:09 +0000
- Thread-topic: Nested AutoRelease Pools Crash
> 2009/4/26 Trygve Inda <email@hidden>:
>> - (void)threadMethod:(id)anObject
>> {
>> NSAutoreleasePool* outterPool = [[NSAutoreleasePool alloc] init];
>>
>> NSDictionary* userDefaults = [NSUserDefaults standardUserDefaults]
>> importantValue = [[userDefaults objectForKey:@"myKey"] boolValue];
>>
>> while (1)
>> {
>> NSAutoreleasePool* innerPool = [[NSAutoreleasePool alloc] init];
>>
>> if (![self threadMustExit])
>> [self doStuffWith:importantValue];
>> if (![self threadMustExit])
>> [self doMoreStuff];
>> if (![self threadMustExit])
>> [self doEvenMore];
>>
>> [innerPool release];
>>
>> if ([lock lockWhenCondition:kConditionThreadMustExit])
>> {
>> [lock unlock];
>> break;
>> }
>> }
>>
>> [lock lock];
>> [lock unlockWithCondition:kConditionThreadIdle];
>>
>> [outterPool release];
>> }
>>
>>
>> This crashes the second time through the loop (when innerPool is being
>> created for the second time). Why?
>
> How about posting your real code instead of a weird paraphrase? This
> won't even compile. Aside from the obvious doMoreStuff methods in the
> middle, the lockWhenCondition: method returns void, so if ([lock
> lockWhenCondition:kConditionThreadMustExit]) is not going to compile.
> It's impossible to diagnose a problem when we're not even looking at
> the same code as the code that crashes.
Sorry - the real code is huge and hard to narrow down - working on it.
_______________________________________________
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