Xcode内存图-显示增加的内存使用量-它到底显示了什么? [英] Xcode Memory Graph - showing increasing memory use - what exactly does it show?

查看:110
本文介绍了Xcode内存图-显示增加的内存使用量-它到底显示了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当观看xcode 6(可能还有5)中的调试图时,运行我的应用程序时,由于我在屏幕上放置了更多的特定对象并对其移动进行动画处理,因此内存使用量继续增加.当我删除它时,它似乎并没有减少.删除后,我相信将不再有对其的引用.

When watching the debug graph in xcode 6 (and probably 5 too), when running my application the memory use continues to rise as I place more of a certain object on the screen and animate it's movement. It does not seem to decrease when I remove it. Once removed I believe there are no more references to them.

查看屏幕截图: http://i.stack.imgur.com/SnhbK.png

但是,当我使用Instruments尝试确定正在发生的事情时,只有大约12mb的持续时间,并且总字节数继续如预期的那样增长.

However when I use Instruments to try to identify what's going on, there's only around 12mb persisting, and Total Bytes continues to rise, as expected.

查看屏幕截图: http://i.stack.imgur.com/VBwce.png

这是正常行为吗?Xcode中显示的图形到底是什么?我在俯视什么吗?

Is this normal behaviour? What exactly is the graph in Xcode showing? Am I overlooking something?

在工具"中,对于上面的屏幕截图,我将分配寿命"设置为所有分配",并将分配类型"设置为所有堆"和匿名VM".

In Instruments I have Allocation Lifespan set to All Allocations and Allocation Type set to All Heap and Anonymous VM for the screenshots above.

更新

通过使用带有活动监视器的仪器,我可以看到实内存"的增长速度与Xcode中显示的速度相同.@Mark Szymczyk指出OpenGL ES Texture内存分配未在分配"工具中显示.

By running Instruments with Activity Monitor I was able to see that the "Real Memory" was increasing at the same rate as is displayed in Xcode. @Mark Szymczyk pointed out that OpenGL ES Texture memory allocations are not shown in the Allocations instrument.

通过在Cocos2D 3.1中定期使用以下命令清除纹理缓存,内存使用率始终下降到18mb左右,并随着我添加更多精灵而再次增加.

By purging the texture cache with the following command in Cocos2D 3.1 at regular intervals, memory use consistently drops back down to around 18mb and begins increasing again as I add more sprites.

[[CCDirector sharedDirector] purgeCachedData];

感谢Mark Szymczyk指出我的方向-谢谢!

Credits go to Mark Szymczyk for pointing me in this direction - thanks!

推荐答案

查看您的屏幕快照,Xcode图形可能显示与Instruments屏幕快照中的Total Bytes列等效.删除对象时,持久字节将减少,但总字节不会减少.这可以解释为什么内存使用量在Xcode图中永远不会下降.

Looking at your screenshots, the Xcode graph is probably showing the equivalent of the Total Bytes column in your Instruments screenshot. When you remove an object, the persistent bytes will decrease, but the total bytes won't. That would explain why the memory use never goes down in the Xcode graph.

Instruments中的"Persistent Bytes"列是确定应用程序的内存使用情况所要查看的.

The Persistent Bytes column in Instruments is what you should be looking at to determine your app's memory usage.

这篇关于Xcode内存图-显示增加的内存使用量-它到底显示了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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