• 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 not sending release message to contained objects at dealloc time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary not sending release message to contained objects at dealloc time


  • Subject: Re: NSMutableDictionary not sending release message to contained objects at dealloc time
  • From: mmalcolm crawford <email@hidden>
  • Date: Fri, 11 Apr 2003 19:19:34 -0700

On Friday, April 11, 2003, at 04:02 PM, Greg Hurrell wrote:

Yet while array sends a release when objects are removed, the dict only sends a release when it itself is deallocated (according to you, and I defer to your experience on this one!)

Umm, no, it doesn't, and Greg didn't say that.


NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSMutableDictionary *md = [NSMutableDictionary dictionary];
RetainReporter *rr = [[RetainCounter alloc] init];\

NSLog(@"About to add rr to md");
[md setObject:rr forKey:@"rr"];

NSLog(@"About to release rr");
[rr release];

NSLog(@"About to remove rr from md");
[md removeObjectForKey:@"rr"];

NSLog(@"About to release pool");
[pool release];


About to add rr to md
retain
About to release rr
release
About to remove rr from md
release
dealloc
About to release pool


Please, sit back for a moment, and think about it a little more. Cocoa memory management is usually *easier* than most people make it for themselves...

<http://www.stepwise.com/Articles/Technical/2001-03-11.01.html>

See in particular the last paragraph.

mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSMutableDictionary not sending release message to contained objects at dealloc time
      • From: Greg Hurrell <email@hidden>
References: 
 >Re: NSMutableDictionary not sending release message to contained objects at dealloc time (From: Greg Hurrell <email@hidden>)

  • Prev by Date: Re: [OT?] Nib files balloon app size
  • Next by Date: Re: [OT?] Nib files balloon app size
  • Previous by thread: Re: NSMutableDictionary not sending release message to contained objects at dealloc time
  • Next by thread: Re: NSMutableDictionary not sending release message to contained objects at dealloc time
  • Index(es):
    • Date
    • Thread