2009/4/26 Trygve Inda <cocoa...@xericdesign.com>: > - (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. > I need to drain the pool each time through the inner loop. I am not using > Garbage Collection. > > Thread 4 Crashed: > 0 libobjc.A.dylib 0x9557f688 objc_msgSend + 24 > 1 com.xericdesign.earthdesk.core 0x00008b3c 0x1000 + 31548 > 2 com.apple.Foundation 0x92a0e7ed -[NSThread main] + 45 > 3 com.apple.Foundation 0x92a0e394 __NSThread__main__ + 308 > 4 libSystem.B.dylib 0x90e7b095 _pthread_start + 321 > 5 libSystem.B.dylib 0x90e7af52 thread_start + 34 Looks like a pretty standard memory mismanagement crash to me. Turn on zombies and start seeing what's being over-released. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com