cc.AssetManager.Bundle.releaseAll not working. v2.4.8

I have 2 bundles: resources and other one local bundle that i load manually.
The second bundle has resources like spine, textures, sounds, etc.

It is how i load the second bundle. Nothing else. I don’t have other code in my project. It is a simple test.

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {
    protected load() {
        this.loadRemote().then(bundle => {
            console.log('TEST', bundle.get('001/texture/00_lobby', cc.SpriteFrame)?.name)
        })
    }

    private release() {
        const b = cc.assetManager.getBundle('rooms')
        if (b) {
            b.releaseAll()
            console.log('TEST', b.get('001/texture/00_lobby', cc.SpriteFrame)?.name)
            cc.assetManager.removeBundle(b)
        }
    }

    private loadRemote() {
        return new Promise<cc.AssetManager.Bundle>((resolve, reject) => {
            cc.assetManager.loadBundle('rooms', (err, bundle) => {
                if (bundle) {
                    const promises: Promise<void> []= []

                    promises.push(this.loadDir(bundle, '001/prefab', cc.Prefab))
                    promises.push(this.loadDir(bundle, '001/sound', cc.AudioClip))
                    promises.push(this.loadDir(bundle, '001/texture', cc.SpriteFrame))
                    promises.push(this.loadDir(bundle, '001/texture', sp.SkeletonData))

                    promises.push(this.loadDir(bundle, '002/prefab', cc.Prefab))
                    promises.push(this.loadDir(bundle, '002/sound', cc.AudioClip))
                    promises.push(this.loadDir(bundle, '002/texture', cc.SpriteFrame))
                    promises.push(this.loadDir(bundle, '002/texture', sp.SkeletonData))

                    promises.push(this.loadDir(bundle, '003/prefab', cc.Prefab))
                    promises.push(this.loadDir(bundle, '003/sound', cc.AudioClip))
                    promises.push(this.loadDir(bundle, '003/texture', cc.SpriteFrame))
                    promises.push(this.loadDir(bundle, '003/texture', sp.SkeletonData))

                    promises.push(this.loadDir(bundle, '004/prefab', cc.Prefab))
                    promises.push(this.loadDir(bundle, '004/sound', cc.AudioClip))
                    promises.push(this.loadDir(bundle, '004/texture', cc.SpriteFrame))
                    promises.push(this.loadDir(bundle, '004/texture', sp.SkeletonData))

                    Promise.all(promises).then(() => {
                        resolve(bundle)
                    }).catch(() => {
                        reject()
                    })
                } else {
                    reject()
                }
            });
        })
    }

    private loadDir(bundle: cc.AssetManager.Bundle, dir: string, asset: typeof cc.Asset) {
        return new Promise<void>((resolve, reject) => {
            bundle.loadDir(dir, asset, (err, asset) => {
                if (asset) {
                    resolve()
                } else {
                    reject()
                }
            })
        })
    }
}

As you see i do nothing with resources from the bundle.

Before the bundle loaded

After the bundle loaded

After the bundle released

Nothing happened. The memory was not released.

1 Like

I would be happy to ask engineering to have a look.

@zzf_Cocos @linrm Can you give us some comments about this please?

Any update on this?

You can call cc.sys.garbageCollect() on the next frame and observe the memory situation after a while.

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