views:

1321

answers:

1

I'm using a separate NSAutoReleasePool for my thread

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
[self bulkyFunction]; // time consuming op
[self performSelectorOnMainThread: @selector(doneAll) withObject:nil waitUntilDone:NO];
[pool release];

and I call a function (bulkyFunction) that allocates two strings.

 currentTitle = [[NSMutableString alloc]init];
 currentSummary = [[NSMutableString alloc]init];

I release them after using.

This thread is called periodically. But when it's called the second time, accessing currentTitle crashes.

Is it because my [pool release] statement releases currentTitle which has already been released by [currentTitle release] statement? Because, if the [currentTitle release] is commented out, there is no problem. But i'm worried about memory leaks.

Please advice.

+3  A: 

[pool release] will not release currentTitle unless you call [currentTitle autorelease] somewhere. I think it would be helpful if you posted the entirety of bulkyFunction.

Steven Canfield