我知道这一定是简单的东西,我俯瞰,但为什么这泄漏:NSAutoreleasePool泄漏
//add a pool for this since it is on its own thread
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//add the image
NSURL * imageURL = [NSURL URLWithString:[recipeData objectForKey:@"imagePath"]];
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage * image = [UIImage imageWithData:imageData];
UIImageView * myImageView = [[UIImageView alloc] initWithImage:image];
//resize to make it fit the screen space
CGRect frame = myImageView.frame;
frame.size.width = 320;
frame.size.height = 357;
myImageView.frame = frame;
[self.view addSubview:myImageView];
[activity stopAnimating];
[pool drain];
[self placeItems];
我得到的错误:
_NSAutoreleaseNoPool():对象0x4e2fdf0类NSPathStore2自动释放与没有到位的地方 - 只是漏水
我试着移动[pool drain]的位置,但是什么也没做。在Google搜索某个原因时,我看到很多代码看起来就像这样。
感谢您的帮助。
您正在泄漏`myImageView`(它需要被释放)。除此之外,乍一看,一切都很好。 – kubi 2011-01-19 15:44:38