Load and release assets

Hi all!
for our game editor we need to load and release assets for build our game levels. For not sill in memory all texture we use cc.resources.load. The trouble; we have see that in browser the memory grow every time we change assets set, maybe the prev assets is not released… is it possible?
our steps are when we load and set assets:

1: cc.resources.load …
2: create objects from assets load
3: … use assets…
4: change assets
5: clear every objects created with assets
6: cc.assetManager.releaseAsset(object assets) for every assets
7: GOTO 1

what we wrong?
many thanks for help!
Stefano

the cc.assetManager.assets count not grow so maybe is ok?

Between 6 and 7, try this, see if it works

cc.sys.garbageCollect()

now we have other trouble… :sob: when we load a new scene, the scene is not loaded correctly… missing many texture… the strange is that this texture are not loaded from cc.resources.load… few idea?
Thanks for help!

ha, there isn’t any error in console (webgl or other)

Hi!
here a sample where don’t works loading scene from other scene…

if we try load scene ‘test/test’ from scene ‘test_loading’ the scene is load without texture. If we load directly ‘test_loading’ works. :confused:

here a video link to explain out trouble Dropbox - File Deleted

any idea what happen? thanks for help

@SantyWang sorry we tag you, do you have any idea for this trouble?
Thanks for help :blush:

Check on the editor if the scene asset is marked as auto release assets. If it is, it will mark all the assets as dirty, and if you garbage collect them, they will be removed from memory

I have seen your demo, the problem is this line in your code:
cc.macro.CLEANUP_IMAGE_CACHE = true.

This macro only can be changed before engine init.

1 Like

THANKS!!! we have add this line maybe from other suggest in other post… and we have forgot this line.
many thanks for help you have save us :smiley:

we had this line for this other trouble, but we analyze in the next build this trouble.
https://184.169.198.12/t/trouble-with-draw-calls-on-android-device/52183/4

If you need to add this line to your code, note that it must be in the outermost layer of your code so that it can be executed before the engine initializing

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.