0
votes

Here is my question. Empty cocos2d project has weight 3.38 MB (standart "Hello world"). I check it by the Profile->Allocate Kit. Now I have a .png image with a size 382x512 pixels. It will be extended to 512x512 in the RAM (2 degree). I add this file to project just like this:

CCSprite* sprite = [CCSprite spriteWithFile:@"mySprite.png"];

And now the most interesting. "mySprite.png" has a 8888 pixel format, i.e. it must occupie 512x512 = 0.5*0.5 = 0.25 MB * 4 = 1 MB (4 - 4 bytes from the pixel format). Am I right? I think so, but when I checked how much the project weight, I found that the project has the 5,54 MB, i.e. "mySprite" has oppupied > 2 MB in the RAM.

What am I doing wrong? And how can I fix it? :/ Thx.

1

1 Answers

0
votes

I remember reading somewhere about this. I went through the cocos2d forums and found this post: http://www.cocos2d-iphone.org/forum/topic/4510

You should check Karl's explanation which seems to make sense for me:

It takes up 8MB because the loader routine uses the OS to load a UIImage, and then copies the pixels to a newly allocated buffer in a GL-friendly 32-bit format. This means that your 1024x1024 image will take 8MB to load, but 4MB of that should be freed once the UIImage gets released...