Re: Instruments leaks.
Re: Instruments leaks.
- Subject: Re: Instruments leaks.
- From: Sandro Noel <email@hidden>
- Date: Sun, 12 Oct 2008 11:00:06 -0400
Fritz.
description is a local function variable, but at this particular point
it is getting replaced by the new assignation.
description = [description trimWhiteSpace];
and access to the pointer of the old value will be lost.
at least that's what I understand.
but i wonder, will the variable automatically be released when it
falls out of scope? i don't think so but i might be wrong.
i'll have to look it up in the doc again :)
Thank you for the language correction :) i'll remember it :)
Sandro.
On 12-Oct-08, at 10:35 AM, Fritz Anderson wrote:
On 11 Oct 2008, at 11:31 PM, Sandro Noel wrote:
for instance, the leek tells me that i have a leek here in this
functions.
it is a NSString categorie.
- (NSString *) trimWhiteSpace {
NSMutableString *s = [[self mutableCopy] autorelease];
CFStringTrimWhitespace ((CFMutableStringRef) s);
return (NSString *) [[s copy] autorelease];
} /*trimWhiteSpace*/
and the way the function is being used is like this.
description = [description trimWhiteSpace];
i'm still looking into understanding, so it's kind of hard for me
to be more precise, i'm sorry...
The question is then what happens to the "description" pointer later.
Suppose "description" is an instance variable. Do you later retain/
copy it? When you make the assignment you show, into "description,"
do you first release/autorelease the old value (if you had retained/
copied/alloced it)?
It's that sort of history, of what you do later with the pointer,
that determines whether the pointer has been leaked.
Another thought: It appears you are not using garbage collection,
but are you? I understand -- someone please correct me --
Instruments/Leaks is not accurate under GC.
By the way, the word you want is "leak." A "leek" is a vegetable.
— F
--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- <http://x3u.manoverboard.org/
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden