为什么XCode&仪器内存使用,是否确定? [英] Why the huge difference between XCode & instruments memory usage, and is it ok?

查看:147
本文介绍了为什么XCode&仪器内存使用,是否确定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用XCode 7.0与iOS 9.0 SDK& ARC,在iOS 5的iPhone 5S上进行的所有性能测试/测试。 EDIT :对于所有屏幕截图,它是一次运行:我直接从xcode运行调试生成,然后手动连接仪器。所以屏幕截图都来自完全相同的单个测试运行。这个内存增长(每个xcode视图)是100%可重现。

I'm using XCode 7.0 with iOS 9.0 SDK & ARC, all profiling/testing done on an iPhone 5S with iOS 9. EDIT: for all screenshots, it was a single run: I ran a debug build straight from xcode, and then manually attached Instruments to it. So the screenshots are all from the exact same single test run. This memory growth (per xcode view) is 100% reproducible.

我的应用程序下载ZIP文件,解压它们,并将它们添加到相机胶卷。我已确保配置文件并捕获内存泄漏(即缺少CGContextRelease)以及使用 @autoreleasepool

My app downloads ZIP files, unpacks them, and adds them to the camera roll. I've made sure to profile and catch memory leaks (ie. missing CGContextRelease) as well as using @autoreleasepool etc

在解压缩期间,在xcode我看到内存使用率快速拍摄,永远不会结束,直到解压缩完成,我不能解释这一点,因为没有在仪器,我可以看到被持有的对象。内存永远不会释放(每个xcode的内存视图)。在我的测试运行结束时,我看到236MB使用,在解压缩期间没有内存警告。如果我使用Instruments的分配工具,我看到50.2MB的堆和匿名VM使用。这是一个巨大的区别!

During unzipping, in xcode I see the memory usage shooting up fast, never-ending until the unzipping finishes, and I cannot explain this because there are no objects in Instruments that I can see being held onto. The memory is never released (per xcode's memory view). At the end of my test run I see 236MB used, with no memory warnings during unzipping. If I use Instruments' allocation tool, I see 50.2MB of heap and anonymous VM used. That's a huge difference!

我做的第一件事是假设 [UIImage imageNamed:因为我有很多动画的UIImageViews,所以我花了时间删除所有imageNamed从我的代码,并使用 imageWithContentsOfFile 代替。这根本没有帮助。我添加解压缩的图像到相机胶卷与iOS 8照片框架像这样: [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:[NSURL fileURLWithPath:filePath]]

The first thing I did was assume that [UIImage imageNamed:was to blame (caching etc) because I have quite a few animated UIImageViews, so I spent time removing all imageNamed from my code, and using imageWithContentsOfFile instead. That didn't help at all. I add the unzipped images to the camera roll with iOS 8 Photo framework like this: [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:[NSURL fileURLWithPath:filePath]]

我花了相当多的时间通过仪器和网络文章,但无济于事。任何人都可以回答这些问题?

I've spent considerable time pouring through Instruments and web articles but to no avail. Can anyone answer these questions?


  1. 为什么xcode内存使用率与仪器 - 这是正常的吗?

  2. 我假设这些数字太高,不能发布这样的应用程序,我必须改进这个,然后我上传到应用程序商店,对吗? >
  3. 查看下面的屏幕截图,您可以在哪里可以开始寻找问题的任何建议?

非常感谢您的帮助。当然,我会发布任何源代码,这将有助于,我只是不知道从哪里开始...

Thank you very much in advance for your help. Of course i'll post any source-code that would help, i'm just not sure where to begin...

XCODE内存使用236 MB

XCODE MEMORY USAGE 236 MB

INSTRUMENTS

INSTRUMENTS

推荐答案

最常见的原因是您的配置。默认情况下,当您在Xcode中运行时,您将在调试模式下构建。在Instruments中配置文件时,默认情况下,它会构建Release。您可以在计划中修改运行和配置文件配置,以更改此设置。

The most common cause of this is your configuration. By default when you run in Xcode, you build in Debug mode. When you profile in Instruments, by default, it builds Release. You can modify your Run and Profile configurations in your scheme to change this.

这篇关于为什么XCode&仪器内存使用,是否确定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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