cocos2d: memory question adding child to scenes

Member
Posts: 164
Joined: 2010.10
Post: #1
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
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #2
I don't see anything you posted above to suggest that, but keep in mind: 1024x1024 is a rather large image.
Quote this message in a reply
Member
Posts: 164
Joined: 2010.10
Post: #3
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
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2011.02
Post: #4
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.
Quote this message in a reply
Member
Posts: 164
Joined: 2010.10
Post: #5
.....
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
Quote this message in a reply
Member
Posts: 164
Joined: 2010.10
Post: #6
i have found that cocos2d make 2 malloc: here the stack tree:
stack tree
[Image: immaginetl.png]
can i avoid that?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
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.
Quote this message in a reply
Member
Posts: 164
Joined: 2010.10
Post: #8
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
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
correct. Profile the device; the simulator is (near) meaningless.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Adding lots of static shapes in Chipmunk - performance question TomorrowPlusX 3 7,268 Jul 11, 2011 01:39 PM
Last Post: Skorche
  Child Units grazhoper 1 2,641 Sep 2, 2009 12:25 AM
Last Post: AnotherJake
  Adding static gravity object game_ding 4 4,805 Mar 28, 2008 05:25 PM
Last Post: Skorche
  how to call fathers setNeedsDisplay from child. iluzone 5 6,213 Dec 7, 2006 04:11 AM
Last Post: iluzone
  Adding message handlers rove 3 4,065 Mar 13, 2005 08:53 AM
Last Post: sealfin