Skip to content

Asset memory is not free correctly because registry attribute is still binded #3886

Description

@lukasharing

engine/src/asset/asset.js

Lines 490 to 515 in 771201a

unload() {
if (!this.loaded && this._resources.length === 0)
return;
this.fire('unload', this);
this.registry.fire('unload:' + this.id, this);
const old = this._resources;
// clear resources on the asset
this.resources = [];
this.loaded = false;
// remove resource from loader cache
if (this.file) {
this.registry._loader.clearCache(this.getFileUrl(), this.type);
}
// destroy resources
for (let i = 0; i < old.length; ++i) {
const resource = old[i];
if (resource && resource.destroy) {
resource.destroy();
}
}
}

to

 unload() {
        if (!this.loaded && this._resources.length === 0)
            return;

        this.fire('unload', this);
        this.registry.fire('unload:' + this.id, this);

        const old = this._resources;

        // remove resource from loader cache
        if (this.file) {
            this.registry._loader.clearCache(this.getFileUrl(), this.type);
        }

        // clear resources on the asset
        this.resources = null;
        this.registry = null;
        this.loaded = false;

        // destroy resources
        for (let i = 0; i < old.length; ++i) {
            const resource = old[i];
            if (resource && resource.destroy) {
                resource.destroy();
            }
        }
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions