【发布时间】:2013-10-03 10:29:36
【问题描述】:
我正在使用 xcode 4 中的分析器来确定我是否有任何内存泄漏。我以前没有这个泄漏,但是使用 xcode 5 我有这个。
我正在尝试为我的 `UIViewController 的选项卡项设置图像,并且分析器标记了这一行:
image = [[UIImage alloc] initWithContentsOfFile:imgPath]; <<=== Leak : 9.1%
这是我的代码的一部分,我不明白为什么。解决此问题的最佳方法是什么?
NSString *imgPath;
UIImage *image;
IBNewsViewController *newsView = [[IBNewsViewController alloc] initWithURL:[tvLocal urlFlux] title:@"News" isEmission:NO];
[newsView setTitle:@"News"];
imgPath = [[NSBundle mainBundle] pathForResource:"news" ofType:@"png"];
image = [[UIImage alloc] initWithContentsOfFile:imgPath]; <<=== Leak : 9.1%
newsView.tabBarItem.image = image;
[image release];
image = nil;
UINavigationController* navNew = [[UINavigationController alloc] initWithRootViewController:newsView];
[newsView release];
newsView = nil;
编辑: iOS6 上没有泄漏。
为什么会在 iOS7 上泄露?
【问题讨论】:
标签: objective-c memory uiimage memory-leaks