• 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: Andy Lee <email@hidden>
  • Date: Mon, 15 Dec 2008 23:56:18 -0500

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.

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

_______________________________________________

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: proper way to release a static NSMutableDictionary?
      • From: Jean-Daniel Dupas <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>)

  • Prev by Date: Re: Main Thread autorelease pool, memory usage question?
  • Next by Date: 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