Re: autorelease - when is retain count decremented
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