2011-05-03 6 views
0

아래 코드에서 메모리 누수를 제거 할 수있는 방법을 찾을 수 없습니다. 도와주세요.NSMutableDictionary 메모리 누수

// Data Transfer from pList and temp & dict Creation --------------------------------------------- 

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // pool is created 

//Path get the path to Data.plist 
NSString *path=[[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"]; 

//Next create the temp dictionary from the contents of the file 
NSMutableDictionary *temp=[NSMutableDictionary dictionaryWithContentsOfFile:path]; 

//Copy from temp and init dict 
dict = [[NSMutableDictionary alloc]initWithDictionary:temp]; 


[pool drain]; 

답변

2

해당 코드에는 누수가 없습니다. 가능한 일은 [dict release]을 잊는 것입니다. 즉 dict에 의해 생성되고 참조 된 NSMutableDictionary은 절대로 출시되지 않습니다.

+0

나는 [dict release]를 가지고 있습니다. on - (void) dealloc 그리고 그것을 사용하는 프로그램 루프가 끝나면 다른 곳에서, Instruments Leaks는 내가 제시 한 코드에서 Leeak를 유지합니다 ... Thanks Dave –

0

호출 스택이 더 높아 보이지만 코드 조각을 캡슐화하는 객체의 할당을 해제하지 않은 것 같습니다.