Understanding task_basic_info task resident_size

微笑、不失礼 提交于 2019-11-29 23:41:54

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/18642421/understanding-task-basic-info-task-resident-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!