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:
- You may be using a same texture over and over again which wouldn't increase memory much at all.
- Loading several 1024x1024 sprites is not normal behavior at all.
- The image you are loading may not be compressed much.
- 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.
精彩评论