• 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: NSMutableDictionary Memory Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary Memory Question


  • Subject: Re: NSMutableDictionary Memory Question
  • From: Mike Abdullah <email@hidden>
  • Date: Fri, 23 Mar 2007 17:51:12 +0000

So my understanding is you have an arrangement something like this:


MyObject NSMutableDictionary (instance variable called myDict) NSMutableDictionary (as a dictionary key) NSMutableDictionary (as a dictionary key)

where the objects higher up are retaining the ones below it. All you should have to do is something like:

- (void)dealloc
{
	[myDict release];
	[super dealloc];
}

As you release myDict, it decreases its retain count. In all likely hood, that is enough to deallocate it. As part of its deallocation, the dictionary will release all keys and values, and they in turn may well be deallocated.

You certainly do not need to enumerate through the objects releasing them all; not unless you've screwed up the memory management elsewhere anyway!

Mike.

On 23 Mar 2007, at 17:34, Matt wrote:

So I have a simple question that relates back to basic Cocoa memory management. I have a dictionary with a few other dictionaries as keys as well as a few nsnumbers. When deallocating my object that contains this structure, I'm a bit confused on how to successfully "kill" all retained objects. :)

If I have a mutabledictionary with other mutabledictionaries as keys and send the top-level dic a -removeAllObjects method, and therefore the lower-level dictionaries are giving a release message, do those in turn pass that release message onto their objects? I had looked at a loop with keyEnumerators (although you can't modify the dictionary), iterating through an array of returned keys, etc.

Any general advice is appreciated!

Matt
Mac Fanatic
http://www.macfanatic.net/
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
40mikeabdullah.net


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: NSMutableDictionary Memory Question
      • From: mmalc crawford <email@hidden>
References: 
 >NSMutableDictionary Memory Question (From: Matt <email@hidden>)

  • Prev by Date: Re: Compiler has trouble distinguishing between a class and its superclass
  • Next by Date: Re: NSMutableDictionary Memory Question
  • Previous by thread: Re: NSMutableDictionary Memory Question
  • Next by thread: Re: NSMutableDictionary Memory Question
  • Index(es):
    • Date
    • Thread