仪器显示内存泄漏-Xcode 5/iOS7 [英] Instruments show memory leak - Xcode 5 / iOS7

查看:55
本文介绍了仪器显示内存泄漏-Xcode 5/iOS7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

NSString *bgImageName = [[Useful instance] getRootviewBackgroundImageName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:bgImageName]];
imageView.clipsToBounds = YES;
CGRect rc = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[imageView setFrame:rc];
[self.view insertSubview:imageView atIndex:0];
[imageView release];

在上面的代码中,仪器在第二行显示100%的内存泄漏,而在xcode 4.6中则不是.我现在正在osx 10.8.5上使用xCode 5

Instruments shows 100% and a memory leak at line two in the above code, which was not the case in xcode 4.6. I am working now with xCode 5 on osx 10.8.5

看来,我正确释放了分配的UIImageView(第7行),该行已插入到我的视图的第6行,所以我看不到仪器为什么会发出内存泄漏警告.

It seems, that i properly release the allocated UIImageView (line 7) which gets inserted in my view at line 6, so i can't see why intruments is bringing up a memory leak warning.

有人知道为什么仪器会提出错误的信息(在我看来)吗?

Does anybody know why instuments brings up that (in my opinion) wrong information?

这是仪器屏幕截图,其中包含我泄漏的对象的分配摘要:

here's the instruments-screenshot with the allocation-summary of my leaked object:

UIKit和QuartzCore保留了我的对象,这就是我泄漏UIImageView的原因(或者我对此假设有误吗?).

The UIKit and QuartzCore are retaining my object, which is the reason for my leaking UIImageView (or am I wrong with this assumption?).

UIImageView插入到我的xib文件中引用的视图(一个UIViewController)中.将我添加的UIImageView添加到"self.view"后,如何控制呢?

The UIImageView is inserted to the view (a UIViewController), which is referenced in my xib-file. How can control what happens with my added UIImageView after adding it to 'self.view'?

推荐答案

我在iOS 7上遇到了与Xcode 5相同的问题.经过一些实验后,我注意到在针对iOS 6.1模拟器或针对运行iOS 7的设备(iPhone 5s).基于这些,我只能得出结论,这是误报,并且是iOS 7模拟器中的错误.

I had the same issue with Xcode 5 on iOS 7. After some experimentation I noticed that Instruments does not show a mem leak when running against the iOS 6.1 simulator or against a device (iPhone 5s) running iOS 7. Based on these I can only conclude that this is a false positive and a bug in the iOS 7 simulator.

我更新到Xcode 5.0.1和OS X Mavericks之后,不再出现此问题(我猜这是修复它的第一个,但不能确定).

This issue no longer occurs after I updated to Xcode 5.0.1 and OS X Mavericks (I'm guessing it's the first that fixed it but can't tell for sure).

这篇关于仪器显示内存泄漏-Xcode 5/iOS7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆