Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Estimating memory usage of Cocos2d game

I am using Cocos2d 2.0 with ARC enabled. My game is a random generated game so I need to load/unload textures( spritesheet-batchnode) within a scene in the middle of the game. I am trying to removespriteframesfromfile and remove texture for key for a spritesheet that i wish to unload in the middle. When I use dumpcachedtextureInfo after unloading the sheet, that spritesheet texture doesnot show up in the logs of dumpcachedtextureinfo.

But when I use Instruments/activity monitor to profile my app, the real memory usage doesnot drop after unloading the texture and spritesheet.

Is there a way where dumpcachedtextureinfo will not show a texture that is still in memory? Also, My livebytes column in allocations shows 4 MB.

Also as i read at various places that allocations doesnot show texture memory.

So my allocations live bytes column says 4 MB, my total texture memory as shown with logs of dumpcchedtextureinfo is shown to be 84MB, but memory monitor stills shows real memory usage to be 84+Spritesheet size+ Live Bytes

I am not able to understand this difference?

I am not exiting the scene, so I am not sure if ARC is holding the memory or what?

like image 456
user1847220 Avatar asked Oct 04 '22 15:10

user1847220


1 Answers

Some useful notes for you

  • This Cocos2d memory optimisation explains very well about memory management in Cocos2d.

  • To check total memory allocation use: Instrument->Activity monitor.

enter image description here

enter image description here

  • To check memory leaks use: Instrument-> Leaks enter image description here
like image 118
Guru Avatar answered Oct 28 '22 20:10

Guru