Re: proper way to release a static NSMutableDictionary?
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