• 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: NSCFArray autoreleased with no pool in place
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSCFArray autoreleased with no pool in place


  • Subject: Re: NSCFArray autoreleased with no pool in place
  • From: Greg Parker <email@hidden>
  • Date: Fri, 15 May 2009 15:52:17 -0700

On May 14, 2009, at 9:58 PM, Tron Thomas wrote:
That did the trick. The stack trace allowed me to track down the cause of the error. Because Objective-C++ does not have a concept of class static variables I had an NSArray defined in an anonymous namespace in the implementation module that was initializing its contents. I changed the code so the array is initially set to nil in the anonymous namespace, and then assign it to an NSArray instance the init method of the class using the array if the array had not been initialize.

I'm guessing the code you just wrote is not thread-safe - if two threads are simultaneously the first to call -init then things might go wrong. If you need thread-safe initialization, the +initialize or +load methods are usually better.



-- Greg Parker email@hidden Runtime Wrangler


_______________________________________________

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


  • Follow-Ups:
    • Re: NSCFArray autoreleased with no pool in place
      • From: Tron Thomas <email@hidden>
    • Re: NSCFArray autoreleased with no pool in place
      • From: Tron Thomas <email@hidden>
References: 
 >NSCFArray autoreleased with no pool in place (From: Tron Thomas <email@hidden>)
 >Re: NSCFArray autoreleased with no pool in place (From: Clark Cox <email@hidden>)
 >Re: NSCFArray autoreleased with no pool in place (From: Tron Thomas <email@hidden>)

  • Prev by Date: Re: Categories and splitting an app into logical blocks.
  • Next by Date: IP detection code by country
  • Previous by thread: Re: NSCFArray autoreleased with no pool in place
  • Next by thread: Re: NSCFArray autoreleased with no pool in place
  • Index(es):
    • Date
    • Thread