Re: new to memory mgmt
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.