substringWithRange: memory leak problem
substringWithRange: memory leak problem
- Subject: substringWithRange: memory leak problem
- From: John Clayton <email@hidden>
- Date: Mon, 26 Sep 2005 21:33:39 -0400
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:
This email sent to email@hidden