Re: substringWithRange: memory leak problem
Re: substringWithRange: memory leak problem
- Subject: Re: substringWithRange: memory leak problem
- From: John Clayton <email@hidden>
- Date: Tue, 27 Sep 2005 06:42:07 -0400
Well, hmm. I am setting them as instance variables in another
object, but those are retained/released appropriately as far as I can
tell.
On Sep 26, 2005, at 9:52 PM, Jonathan del Strother wrote:
Are you later retaining myString anywhere? IIRC, MallocDebug only
reports where the string was created, rather than where it's gotten
retained...
On 27 Sep 2005, at 02:33, John Clayton wrote:
Hi,
MallocDebug is telling me I have a memory leak in some code like
this:
- (void) parse:(NSString *)someString {
NSArray *myArray= [someString componentsSeparatedByString:@"\n"];
int i, count = [myArray count];
for(i = 0; i < count; i++) {
NSString *line = [myArray objectAtIndex:i];
NSString *slice = [line substringWithRange:someRange];
NSString *myString = [slice stringByTrimmingCharactersInSet:
[NSCharacterSet
whitespaceCharacterSet]];
}
}
The leak is tracked down to a call graph like (inverted):
substringWithRange: -> stringByTrimmingCharactersInSet
Now, as far as I can tell both of those methods return an
autoreleased string. And, releasing or autoreleasing either of
them actually does result in bad memory access.
Wow, stumped.
Any ideas? I can send an actual method if that helps, but it's a
bit longer.
Thanks, cocoa-folk.
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40steelskies.com
This email sent to email@hidden
_______________________________________________
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