• 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: proper way to release a static NSMutableDictionary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proper way to release a static NSMutableDictionary?


  • Subject: Re: proper way to release a static NSMutableDictionary?
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Tue, 16 Dec 2008 09:28:45 +0100


Le 16 déc. 08 à 05:56, Andy Lee a écrit :

On Dec 15, 2008, at 6:27 PM, John Michael Zorko wrote:
I'm not concerned about the contents per se -- i'm concerned about releasing something I declared as static, just to create it again later.

Creating and re-creating objects is in itself nothing to be afraid of. It happens all the time.


The main relevant difference between the two approaches -- (1) empty the existing dictionary, or (2) release the existing dictionary and make a new dictionary -- is that in the latter case, it's conceivable that some object or thread might be caching a stale reference to the old dictionary. This might or might not be a real concern in your specific app.

Catching a stale reference or accessing a dictionary in a non thead safe way. I don't know what is the worst.



I wonder if you are concerned not because 'lookup' is static (which has a specific meaning), but because the variable is globally visible and is referred to all over the place, and therefore possibly at greater risk for the stale-reference problem? But if that's your concern, then you've answered your own question: just go with [lookup removeAllObjects].


--Andy

Part of me is saying "just release the dictionary's contents, not the dictionary itself".

Regards,

John


_______________________________________________

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


References: 
 >proper way to release a static NSMutableDictionary? (From: John Michael Zorko <email@hidden>)
 >Re: proper way to release a static NSMutableDictionary? (From: Ashley Clark <email@hidden>)
 >Re: proper way to release a static NSMutableDictionary? (From: John Michael Zorko <email@hidden>)
 >Re: proper way to release a static NSMutableDictionary? (From: Andy Lee <email@hidden>)

  • Prev by Date: Swap subviews of NSSplitView? (SOLVED)
  • Next by Date: Re: Swap subviews of NSSplitView?
  • Previous by thread: Re: proper way to release a static NSMutableDictionary?
  • Next by thread: Re: proper way to release a static NSMutableDictionary?
  • Index(es):
    • Date
    • Thread