• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Nested AutoRelease Pools Crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nested AutoRelease Pools Crash


  • Subject: Re: Nested AutoRelease Pools Crash
  • From: Reinhard Segeler <email@hidden>
  • Date: Fri, 5 Jun 2009 13:45:24 +0200

Maybe you solved the problem in the meantime, otherwise I recommend to use the solution below, which I use in my app - without the if condition with break - and works fine

Am 26.04.2009 um 18:37 schrieb Trygve Inda:

- (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];

should be here: [innerPool release];


break;

cause after break, the innerpool would otherwise not be released


}

and set it here: [innerPool release];


}

  [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?

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



_______________________________________________

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:
@segeler.biz


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


  • Prev by Date: Making an NSButton appear selected.
  • Next by Date: Re: Set icon for files created
  • Previous by thread: Re: Making an NSButton appear selected.
  • Next by thread: Wich one is faster, compare or isEqualToString? (NSString methods)
  • Index(es):
    • Date
    • Thread