Unloading resources?

Hi, I’ve noticed how the common strategy for dealing with resources in cocos2d-html5 examples is to just preload everything at the beginning.

But if I wan’t my game to need as little memory as possible, it’d be a better idea to load only the resources I need for the next level, and then unload them when I don’t need them anymore. Is there a way to do that?

Hi,

I’m not sure there is some reliable and stable solution for this, maybe this topic on StackOverflow can help you: http://stackoverflow.com/questions/7488866/unloading-resources-on-html-with-javascript

Huabin

Thanks!

I’ll try the manual delete / set to null + call CollectGarbage()…

I was wondering if rather cocos2d-html5 implements an autorelease pool like cocos2d-x: http://zilongshanren.com/blog/2013/12/20/what-is-autorelease-pool/

Or if another method has been tested and proved and stable approach to this. I’ll guess we’ll have to add it to the checklist if not? :wink:

We may will integrate a ObjectPool mechanism into cocos2d-html5, but it’s not sure yet. However, a global autorelease pool or garbage collection is not something we plan todo, using javascript to do such thing will only make things worse.

Thanks, I’ll keep an eye on the news.

I’d like to be able to help, but sadly I’m not that familiar with JS’s garbage collection and neither the memory allocation proccess of cocos2d. Even though performance and memory usage worry me.

edit: I just saw this issue regarding that, althought it seems to be an “unplanned” feature now? http://cocos2d-x.org/issues/2461

Yes, It’s in discussion now, but we are not yet sure about its use case and if it is a essential need.