2010-06-22 41 views
1

我正在使用仪器来查找内存泄漏,它发现了很多! 但我不知道如何解决它。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

由于wycategoriesretain属性,你有assignement后释放该数组。

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