• 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: I think I get most of the memory stuff but...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I think I get most of the memory stuff but...


  • Subject: Re: I think I get most of the memory stuff but...
  • From: Scott Anguish <email@hidden>
  • Date: Mon, 5 May 2003 03:32:05 -0400

On Monday, May 5, 2003, at 02:27 AM, Jeffrey Mattox wrote:

At 10:00 PM -0400 5/4/03, Sherm Pendley wrote:
This does precisely the same thing as your original, but it may help illustrate that you're retaining the iVar to which the incoming parameter is assigned, not the parameter itself:

-(void)setClientCode:(NSString *) aString {
[clientCode release];
clientCode = aString;
[clientCode retain];
}

I like that sequence better, but what if aString and clientCode are the same object, as Tony pointed out? Would it work to do it this way (use autorelease instead):

-(void)setClientCode:(NSString *) aString {
[clientCode autorelease];
clientCode = aString;
[clientCode retain];
}

That does not guarantee another release if clientCode is already in the autorelease pool, but could it be?


It's better to retain and then release rather that autorelease and then retain.

autorelease is slower, and if you don't need it to stick around, why autorelease?
_______________________________________________
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: I think I get most of the memory stuff but...
      • From: Sherm Pendley <email@hidden>
    • Re: I think I get most of the memory stuff but...
      • From: j o a r <email@hidden>
References: 
 >Re: I think I get most of the memory stuff but... (From: Jeffrey Mattox <email@hidden>)

  • Prev by Date: Re: I think I get most of the memory stuff but...
  • Next by Date: Re: I think I get most of the memory stuff but...
  • Previous by thread: Re: I think I get most of the memory stuff but...
  • Next by thread: Re: I think I get most of the memory stuff but...
  • Index(es):
    • Date
    • Thread