views:

49

answers:

2

I get a leak on the code below, any idea why? I am not allocating anything so why does it leak? It leaks 32 bytes

NSString *username = @"";
NSString *myString  = @"some text";
NSRange range = [myString rangeOfString:@"username="];
//instrument shows a leak on the line below
username = [myString substringToIndex:range.location + range.length];
//I never release username or myString

alt text

A: 

There shouldn't have any leaks, myString and userName is autoreleased already. Maybe it is not released yet but it will be released in some future time

vodkhang
A: 

It looks as though the String has been autoreleased - so should get released on the next pass through the event loop (#2 shows an autorelease).

RickyTheGeek