• 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: autorelease - when is retain count decremented
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autorelease - when is retain count decremented


  • Subject: Re: autorelease - when is retain count decremented
  • From: Nick Zitzmann <email@hidden>
  • Date: Tue, 14 Sep 2004 15:30:05 -0600


On Sep 14, 2004, at 2:41 PM, justin webster wrote:

NSString *myString = [NSString stringWithFormat:@"testing"];
myString = anotherString;

when I point myString away from the 'testing' string, does the 'testing' memory get freed?

No. The "testing" string has its retain count decremented when the autorelease pool is popped. If the retain count is decremented to 0 in the process, then the object is deallocated.


also, in this situation do I now have two pointers to the same piece of memory, and therefore a retain count of two?

You have two pointers to the same piece of memory, but the retain count is unchanged. If you need to retain something, you must explicitly send it a -retain message.


Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >autorelease - when is retain count decremented (From: justin webster <email@hidden>)

  • Prev by Date: Re: autorelease - when is retain count decremented
  • Next by Date: Re: autorelease - when is retain count decremented
  • Previous by thread: Re: autorelease - when is retain count decremented
  • Next by thread: Re: autorelease - when is retain count decremented
  • Index(es):
    • Date
    • Thread