2009-06-20 6 views
0

내 스레드에 대해 별도의 NSAutoReleasePool 사용하고 있습니다.iPhone SDK를 사용한 멀티 스레딩

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

두 개의 문자열을 할당하는 함수 (bulkyFunction)를 호출합니다.

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

사용 후에 릴리스합니다.

이 스레드는 주기적으로 호출됩니다. 하지만 두 번째 호출 될 때 currentTitle에 액세스하면 충돌이 발생합니다.

내 [풀 릴리스] 문이 [currentTitle release] 문에서 이미 릴리스 된 currentTitle을 릴리스했기 때문에 그럴 수 있습니까? [currentTitle release]가 주석 처리되었으므로 아무런 문제가 없습니다. 하지만 메모리 누수가 걱정됩니다.

조언을주십시오.

답변

4

[pool release][currentTitle autorelease] 을 어딘가에 호출하지 않는 한 currentTitle을 릴리스하지 않습니다. bulkyFunction 전체를 게시하면 도움이 될 것 같습니다.