开发者

substringToString producing leak

Ive been getting a memory leak at the line tempstr = [tempstr substringToIndex... Ive tried every possible combination of allocation tempStr, NSString *tempStr = @""; NSString *tempStr = [[NSString alloc] init]; (with a release at the end of the loop) ive tried adjusting the scope of the NSString. NOTHING. Its producing 3 leaks Any help on what i can try to fix it would be much appreciated.

while(x < [arr1 count]){
            //NSLog(@"%@", [arr1 objectAtIndex:x]);

            if([[arr1 objectAtIndex:x] rangeOfString:@".com"].location != NSNotFound)
            {

                //NSLog(@"%@", [arr1 objectAtIndex:x]);
                tempStr = [[arr1 objectAtIndex:x] substringFromIndex:[[arr1 objectAtIndex:x] rangeOfString:@"http://"].location];
                tempStr = [tempStr substringToIndex:tempStr.length - 1];
                [arr1 replaceObjectAtIndex:x withObject:tempStr];

                //NSLog(@"%@", [arr1 objectAtIndex:x]);开发者_C百科

            }
..... more code....
x++
}


Those tempStr instances should be going to the autorelease pool, thus if you are using the autorelease pool properly, they should be released properly, in due time.

Thus, you are either measuring the leak very early (the objects won't be released until long after the loop is finished), or you are working on a thread where the autorelease pool has not been setup properly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜