2010-06-22 5 views
1

나는 계기를 사용하여 메모리 누출을 발견하고 많은 것을 발견했습니다! 그러나 문제를 해결하는 방법을 모르겠습니다. wycategoriesretain 속성이 있기 때문에NSMutableArray 루프 누수

@property(nonatomic, retain) NSMutableArray *wycategories; 
... 
... 
self.wycategories = [[NSMutableArray alloc]init]; 
... 
... 
for (CXMLElement *node in nodes) {  
    //Instruments say that here there are a lots of memory leaks 
    WaiYahCategory *wycategory = [[WaiYahCategory alloc] init]; 

    wycategory.text = [[node childAtIndex:0] stringValue]; 
    wycategory.idCategory = [[node attributeForName:@"id"] stringValue]; 
    wycategory.desc = [[node attributeForName:@"desc"] stringValue]; 
    wycategory.icon = [[node attributeForName:@"icon"] stringValue]; 

    [self.wycategories addObject:wycategory]; 
    [wycategory release]; 
} 

답변

1

, 당신은 assignement 후 배열을 해제해야합니다.

NSMutableArray *array = [[NSMutableArray alloc]init]; 
self.wycategories = array; // <- The property retains the array 
[array release];