How do we free the memory from the resources that are loaded?

Hi guys…
How do we free the memory from the resources that are loaded?
because i want to switch to my next scene and i want to free the memory from the resources of the previous scene…

please help… :blush:

Memory is handled by cocos for switching scenes if using replace scene. If you want to remove sprite sheets that have been added you can purge the sprite cache

@ChrisS91
but why is it that when i already load a scene along with its assets and then load in in some part of the game… i don’t need to pre-load its assets again… i could just run the scene.
does it mean that the pre-loaded assets doesn’t get destroyed?..

thanks @ChrisS91 :blush:

When you add sprite frames to the cache they are stored there so when you create a sprite it references the file in the cache so only the instances of the objects in the scene are removed it saves re loading all the time.

meaning as long i don’t purge the cache i wont have to worry preloading it?..

but how about the game sounds? does cocos2d store a reference to it too?

thanks man :wink:

On mobile the cache is cleared when the app receives a memory warning, so it’s safer to still use preloading before every scene.

Sounds can be loaded on the fly, it’s not required to preload them. Of course if you have a lot of sounds it will take time to load them, so there can be a delay on first use when they aren’t preloaded.

Hello All,

When we preloaded the resources, the images & Sounds will be saved in Browser. As we load the resources size will be increase. Once it reaches maximum size App receives a memory warning and automatically refresh the Page.
When it refresh the page, browser data will be cleared. This Scenario will be cause crash in game in between.

Is there any method to Deallocate Old preloaded resources from browser to avoid memory warning. 

Thanks,
Gurudath

@Gurudath

so you mean it would be a best practice to make sure that our assets are always preloaded?
but in maintaining good user experience, we should always minimize the loading scenes that our game has…
because you know… :smile: its kinda annoying when our game has too many loading screens…

@eydamson

Yes.

If there is any method to delete or remove Old preloaded resources from browser then plz let us know.
Currently we can have Max 10mb size Game in mobile browser. If we load more resources browser will receive Memory warning and automatically get refreshed.

@Gurudath
you may use cc.loader.releaseAll()

Resource cache of all resources.

@eydamson

I tried by using cc.loader.releaseAll()
Its not releasing all the resources (spine, Spritesheet, texturecache).

In Browser app size will remain same.