了解task_basic_info任务resident_size [英] Understanding task_basic_info task resident_size

查看:379
本文介绍了了解task_basic_info任务resident_size的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简短问题:某人(来自我说驻留内存是对已分配给您的应用程序但尚未被系统回收的内存的度量,但是一些/大部分驻留内存可以由系统回收。



这是否意味着常驻内存值不一定是我的应用程序使用的内存?



根据我的测试,场景与其使用的内存和驻留内存值之间似乎存在相关性。



所以如果这是正确的,我应该继续尝试解决这个问题,因为常驻内存值越高,我的APP就越有可能被杀死。相反,如果系统可以使用内存,那么就不会发生崩溃。鉴于存在崩溃,我认为内存以某种方式泄露。但是泄漏工具没有检测到任何泄漏(这是因为我使用的是XCode 4.5?)。



有什么帮助吗?这与使用ARC有关吗?

解决方案

问题是我在init方法中测量内存新场景。因此,该报告包括前一场景的资产(因为它尚未被解除分配)。



添加0.1延迟的回调解决了它并回答了我的问题:



问:


某人(第5条)告诉我,我的
系统可以回收居民记忆。这是什么意思?这是否意味着我的应用程序没有使用
那个内存,或者是与我的应用程序当前使用的
内存直接相关的驻留内存值?


A:



它是与我的应用程序使用的内存直接相关的内存。使用此功能的回调延迟以及对 [[CCTextureCache sharedTextureCache] dumpCachedTextureInfo]; 将确认这一点。



问:


任何帮助?这与使用ARC有关吗?


A:
幸运的是,不是这种情况。在某些场景中还有其他问题导致泄漏。例如,起始场景是另一个场景的子类。这个起始场景有一些子节点被添加为子节点,在场景的清理方法中没有被删除。添加显式删除这些子节点解决了该问题。我不确定为什么这是必要的(我希望自动删除所有子节点)但它解决了这个问题。


short question: someone (cit. 5) told me that resident memory could be reclaimed by my system. What does this mean? Does it mean that my App is not using that memory or is the resident memory value directly related to the memory being currently used by my App? I haven't found much documentation on this apart from those answers.

I am trying to solve an issue. I am writing a game usign iOS 6.0 and Cocos2d 2.0 and I do get some memory problems. I have Cococs2d 2.0 as static library and I wrote my code using ARC (which I suspect being the reason).

Going from Initial scene to Character Selection Scene and then to Planet Selection scene and finally Game scene I observe that the resident_size of memory increases.

I added this code at each scene init and I tracked down the values. The following picture show the user experience path I do. On the left colum there are the scene names, on the second colum the amount of memory used in the normal flow (not going back to the previous scene) and in the third block of colums there are the values of resident memory going back and forwards from specific scenes.

As we can observe the Main scene presents an issue probably different from the other scenes. Every time I load the scene I get a memory increase of about 15 MB.

I run an indipendent test on the scene (using a reload callback method) and I get the following values:

Interestingly, running the same test on the CharacterSelection Scene does not have a progressive increase of memory after the third load (stays 37MB). However I do not understand why initially goes from 27 MB to 32 MB and NOT to 37MB (or, I should say, I do not understand why it goes from 32 MB to 37 MB).

I run another set of test trying to parse from one scene to the other and I do get interesting results. Here is the schema:

**Someone answered to me saying "Resident memory is a measurement of the memory that has been allocated to your application and has not yet been reclaimed by the system, but some/most of the resident memory could be reclaimed by the system."

Does this mean that resident memory values are not necessarily memory used by my App?

According to my test, there does seem to be a correlation between scenes and their memory used and resident memory value.

So if this is correct I should keep trying to solve this issue as the higher the resident memory value is the more likely my APP is to be killed. If, instead the memory would be available to the system to be used then there would be no crash. Given that there are crashes I assume that the memory is somehow leaked. However the leak tool does not detect any leaks (is this because I am using XCode 4.5?).

Any help? Is this related to using ARC?

解决方案

The issue was that I was measuring the memory during the init method of the new scene. The report was hence including the assets of the previous scene (as it was not yet being deallocated).

Adding a callback with a 0.1 delay solved it and answering my questions:

Q:

someone (cit. 5) told me that resident memory could be reclaimed by my system. What does this mean? Does it mean that my App is not using that memory or is the resident memory value directly related to the memory being currently used by my App?

A:

it is the memory directly related to the memory being used by my App. Using a delay in the callback of this function plus a call to [[CCTextureCache sharedTextureCache] dumpCachedTextureInfo]; will confirm this.

Q:

Any help? Is this related to using ARC?

A: Not in this case fortunately. There where other issues causing leaks in some scenes. For example, the starting scene was subclass of another scene. This starting scene had some child nodes being added as child which where not being removed on the cleanup method of the scene. Adding an explicit removal of those child nodes solved the issue. I am not sure why this was necessary (I was expecting all child nodes to be automatically removed) but it solved the issue.

这篇关于了解task_basic_info任务resident_size的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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