Skip navigation.
 
mlRe: Why shouldn't I release?
FROM : Frank Weinstock
DATE : Sat Dec 01 04:40:18 2007

On Nov 30, 2007, at 10:06 PM, Ric L. wrote:

>
>
>
>

>> CC: <email_removed>
>> From: <email_removed>
>> To: <email_removed>
>> Subject: Re: Why shouldn't I release?
>> Date: Fri, 30 Nov 2007 18:58:59 -0800
>>
>>
>> On Nov 30, 2007, at 6:54 PM, Ric L. wrote:
>>

>>> By my reckoning, stringWithFormat should create a string with a
>>> retain count of 1.

>>
>>
>> Why do you say that? Before you answer, refer to the memory 
>> management
>> policies here:
>>
>> <http://developer.apple.com/documentation/Cocoa/Conceptual/

>> MemoryMgmt/Concepts/ObjectOwnership.html
>
> Well, after I wrote the message, I added a line:
>
>    long retainCount = [outputString retainCount];
>
> after the call to stringWithFormat and saw that it had a retain 
> count of 1 - this would seem to settle the issue that I am correct 
> on this point at least.
>
> However, thanks for the pointer to the site, I will take a close 
> look at it.


True, it has a retain count of 1--if it had a retain count less than 
1 it would have already been deallocated.  stringWithFormat 
autoreleases the string, so it can be released when the autorelease 
pool is flushed.  But, you've already released it by then (causing it 
already to be deallocated); and the deallocated object being released 
causes the crash.

Frank

> _________________________________________________________________
> Your smile counts. The more smiles you share, the more we donate. 
> Join in.
> www.windowslive.com/smile?
> ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline______________________________
> _________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>


****************

Frank Weinstock
Interim Associate Dean for Academic Affairs
Director of Graduate Studies
College-Conservatory of Music
University of Cincinnati
frank.<email_removed>



****************

Frank Weinstock
Interim Associate Dean for Academic Affairs
Director of Graduate Studies
College-Conservatory of Music
University of Cincinnati
frank.<email_removed>

Related mailsAuthorDate
mlWhy shouldn't I release? Ric L. Dec 1, 03:54
mlRe: Why shouldn't I release? j o a r Dec 1, 03:58
mlRe: Why shouldn't I release? Andrew Farmer Dec 1, 04:02
mlRE: Why shouldn't I release? Ric L. Dec 1, 04:06
mlRe: Why shouldn't I release? Hank Heijink Dec 1, 04:15
mlRe: Why shouldn't I release? stephen joseph but… Dec 1, 04:28
mlRe: Why shouldn't I release? Frank Weinstock Dec 1, 04:40
mlRe: Why shouldn't I release? I. Savant Dec 1, 05:08