Skip to content

Memory leak on disposing targets or load project #587

@SimonShiki

Description

@SimonShiki

Expected Behavior

The target's data should be clear when it get disposed.

Actual Behavior

Memory leak happens on both disposing targets or load project.

Steps to Reproduce

  1. Open DevTools, Shot a memory heap snapshot.
  2. Open a large project, like https://scratch.mit.edu/projects/613688710
  3. Shot again.
  4. Create a new project, shot again.

Screenshots

(Init -> Load an large project -> Create a new project)

Image

The Cause

1. _StackFrameFreeList never get clear

_StackFrame holds target, and _StackFrameFreeList will recycle the disposed stack frames. but it never get clear.
A verified fix here: Clipteam/clipcc#237

2. Previous target's skins won't get disposed

This problem has been addressed before (an issue in old scratch-gui repo). A workaround can be considered:

        if (this.renderer && '_allSkins' in this.renderer) {
            this.renderer._allSkins.forEach(skin => {
                this.renderer!.destroySkin(skin._id);
            });
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions