仪器的泄漏告诉我,这UIImage的泄漏:为什么这个泄漏的内存? UIImage的`的cellForRowAtIndexPath:`
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[imagesPath stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@.png", [postsArrayID objectAtIndex:indexPath.row]]]];
// If image contains anything, set cellImage to image. If image is empty, try one more time or use noImage.png, set in IB
if (image != nil){
// If image != nil, set cellImage to that image
cell.cellImage.image = image;
}
image = nil;
[image release];
(类细胞(自定义表格视图单元格)也释放cellImage在dealloc方法)。
我还没有知道它为什么会泄漏的线索,但它当然是。 图像在cellForRowAtIndexPath:
-方法中多次加载。前三个单元格的图像不会泄漏(130px高,所有空间都可用)。
泄漏给我没有其他信息比那个UIImage allocated here in the code leaks
。
你能帮我弄明白吗?谢谢:)
,你会在这种情况下使用什么样的?这两者之间有什么区别:[[UIImage alloc] initWithContentsOfFile:...];和[UIImage imageWithContentsOfFile:...] ;.有没有什么区别? – Emil 2010-06-02 20:29:04