Do sprites and other nodes auto release?

Hi!
Does a sprite node and actually all other nodes release automatically??

Thanks!

All cocos2d::Ref derivatives can be added to the autorelease pool which decrements their reference count at the end of the current frame. All cocos implementations provide a ::create() method which will call autorelease for you on the returned instance. However Ref types will behave like any other type if you use new/alloc to instance them directly.

For more information on the cocos2d-x’s memory management and standard practices read these articles:
http://www.cocos2d-x.org/wiki/Reference_Count_and_AutoReleasePool_in_Cocos2d-x

1 Like

Nice answer! Thanks!
Because my app is lagging very much but I got no idea why so I thought it could be a problem about the release but now I know it is not that…

Do you have any ideas what could cause lagging? (it is a quiz app btw)

Thanks !

What do you mean lagging? Are you experiencing constantly low FPS or spikes in FPS?

Poor performance can be any number of things, from simply unoptimised code to too many objects being rendered. In my experience the first bottle necks you should look for are:

Allocations: make sure you’re not constantly instancing objects by hiding instead of destroying them when not in use and/or pooling and reusing them.

Rendering: Check how many draw calls you’re making every frame. My rule of thumb is to aim for below 20. You can minimise draw calls by batching objects together and making use of spritesheets. Non Power of Two textures can also be a serious bottle neck on mobile hardware as the GPU will pick the next Power of Two size when allocating memory (if your texture is 700x700, GPU will allocate 1024x1024 for it).

Big data: parsers, find/sort operations, nested loops can easily become very expensive very quickly as your data grows. Make sure you’re using appropriate container types and algorithms to minimise their overheads.

I strongly recommend making use of profiling tools to identify bottleneck code regularly. A simple function timer is usually enough to identify places that need work and to assess the payoffs of time spent optimising any particular piece of code.

Thanks so much!! BUT
i have made a test and here is my result: http://s000.tinyupload.com/?file_id=60027499428720512041
My files to should search for is “mainScene”, “quizer”, “HUD” and “pointsystem”…
can u help?
I mean i can’t find the place that makes it lag?

Thanks!!