iDevGames Forums
cocos2d: memory question adding child to scenes - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: cocos2d: memory question adding child to scenes (/thread-8775.html)



cocos2d: memory question adding child to scenes - sefiroths - Apr 1, 2011 06:47 AM

i have started with helloworld template.
added some menu and started performance tool->allocation.
result: 1.9MB
ok, added instance variable ccsprite initialized with an image 1024x1024
and started performance tool->allocation.
result: 6MB
ok, now added to the schen with [self addChild...]
performance tool->allocation.
result: 11MB
is that normal?
every sprite i'll add as child will double my memory usage?
thanks


RE: cocos2d: memory question adding child to scenes - skyhawk - Apr 1, 2011 04:18 PM

I don't see anything you posted above to suggest that, but keep in mind: 1024x1024 is a rather large image.


RE: cocos2d: memory question adding child to scenes - sefiroths - Apr 4, 2011 12:10 AM

sob...
1024x1024 were only for test, because i did an app, i thought the total memory allocated was 15MB, allocation tools gave me 30MB....
if you make the same things i did, how many memory allocation tool give you?
thanks


RE: cocos2d: memory question adding child to scenes - blackfeather - Apr 8, 2011 11:51 AM

I use cocos2d on my game CloudJumper, and it uses maybe 4 sprite sheets at 1024x1024, as well as a few other image resources, and about 20 preloaded sound files. Memory allocation generally hovers around 16-18mb for me.


RE: cocos2d: memory question adding child to scenes - sefiroths - Apr 11, 2011 12:17 AM

.....
could you make this try:
open new helloworld template, add this to init function:
CCSprite bg=[CCSprite spriteWithFile:@"sprite1024x1024.png"];
open allocation tool and see the memory allocated, till now should be 4MB of the image+something (for me 2MB)
now add
[self addChild:bg];
open allocation tool and see the memory allocated, here i get 11MB...
should be fast to try, ca you?
thanks


RE: cocos2d: memory question adding child to scenes - sefiroths - Apr 18, 2011 08:48 AM

i have found that cocos2d make 2 malloc: here the stack tree:
stack tree
[Image: immaginetl.png]
can i avoid that?


RE: cocos2d: memory question adding child to scenes - OneSadCookie - Apr 18, 2011 09:15 AM

You're looking at the simulator, not the device. What you see here does not [necessarily] apply there.

Both the allocations you indicate are in GL and outside Cocos' control.


RE: cocos2d: memory question adding child to scenes - sefiroths - Apr 19, 2011 12:19 AM

so could I have in simulator 2 allocation of 4MB and in device no?
i'm working with device for the first time, so all is new for me.
thanks


RE: cocos2d: memory question adding child to scenes - OneSadCookie - Apr 19, 2011 08:06 AM

correct. Profile the device; the simulator is (near) meaningless.