开发者

cocos2d: alloc ccsprite memory 4MB, adding as child to scenes mem=11MB

开发者 https://www.devze.com 2023-02-22 04:32 出处:网络
i have started with helloworld template. added some menu and started performance tool->allocation. result: 1.9MB

i have started with helloworld template. added some menu and started performance tool->allocation. result: 1.9MB ok, so the empty scene is 2MB now added instance variable ccsprite initialized with an image 1024x1024

CCsprite *test=[CCSprite spriteWithFile:@"img1024x1024.png];

and started performance tool->allocation. result: 6MB ok, the image in memory is 4M开发者_如何学JAVAB, +2MB of the empty now added to the schen with

[self addChild:test];

performance tool->allocation. result: 11MB is that normal? every sprite i'll add as child will double my memory usage? thanks


Adding one sprite and thinking that each sprite will add the same amount of memory allocated is not really logical. Consider the following:

  1. You may be using a same texture over and over again which wouldn't increase memory much at all.
  2. Loading several 1024x1024 sprites is not normal behavior at all.
  3. The image you are loading may not be compressed much.
  4. Depending on the application you are making that memory usage may not be an issue.

If you are really worried about memory usage, I would add the appropriate amount of sprites scaled down the the appropriate size that your application is going to use and add them and check Instruments again.

0

精彩评论

暂无评论...
验证码 换一张
取 消