• 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: new to memory mgmt
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new to memory mgmt


  • Subject: Re: new to memory mgmt
  • From: Troy Dawson <email@hidden>
  • Date: Sun, 15 Feb 2004 12:29:59 -0800

On Feb 15, 2004, at 12:04 PM, pmcurry wrote:

Just looking for some reassurance that I'm starting to understand some parts of memory mgmt.

Code fragment:

switch ( message ) {
<snip>
case: kBegin
Node n = [[Node alloc] init];
[n setRank:a];
[n setParent:b];
[n setState:c];
[tree addObject:n]
[n release];

yes, that is correct.

IMO, what you can do to make it [more] clear that you are just releasing the local retain of the object is to do this instead:

[tree addObject: [n autorelease]];

the autorelease defers any dealloc of the object (if the refcount is 0) until the thread's execution goes back into NSApplicationMain().

But this is just a style thing and not that important.
_______________________________________________
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: new to memory mgmt
      • From: pmcurry <email@hidden>
References: 
 >new to memory mgmt (From: pmcurry <email@hidden>)

  • Prev by Date: Re: ANN: Doxygen for MacOS X with Objective-C support
  • Next by Date: Re: new to memory mgmt
  • Previous by thread: new to memory mgmt
  • Next by thread: Re: new to memory mgmt
  • Index(es):
    • Date
    • Thread