Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch memory leak in Disposable. #330

Closed
Tracked by #933
pixelzoom opened this issue Apr 4, 2023 · 3 comments
Closed
Tracked by #933

Patch memory leak in Disposable. #330

pixelzoom opened this issue Apr 4, 2023 · 3 comments

Comments

@pixelzoom
Copy link
Contributor

pixelzoom commented Apr 4, 2023

For phetsims/qa#924

While reviewing phetsims/scenery-phet#769, @zepumph and I discovered a relatively serious memory leak in Disposable, which is the base class for (among other things) PhetioObject.

From phetsims/scenery-phet#769 (comment), the line added in this diff is missing, so disposeEmitter listeners are not freed.

  public dispose(): void {
    assert && assert( !this.isDisposed, 'Disposable can only be disposed once' );
    this._disposeEmitter.emit();
+   this._disposeEmitter.dispose();
    this.isDisposed = true;
  }

In calculus-grapher, we use disposeEmitter througout GraphTypeLabelNode, which appears as labels for the Notation radio buttons appears in the Preferences dialog: f'(x), f'(t), df/dx, df/dt. An example from GraphTypeLabelNode is:

  label.disposeEmitter.addListener( () => {
    labelStringProperty.dispose();
  } );

In Slack#DM, I asked @zepumph about the above example:

There’s no handle to the listener function, but labelStringProperty is included by closure. Is this going to be a leak? Should we patch in calculus-grapher 1.0 ?

... and he replied:

Patching the Branch seems prudent.

So I'm going to proceed with patching calculus-grapher 1.0, to be tested in the next RC.

@veillette @amanda-phet FYI.

@zepumph
Copy link
Member

zepumph commented Apr 4, 2023

The commit to cherry pick is phetsims/axon@0224337

@pixelzoom
Copy link
Contributor Author

Cherry-picked and patches into axon's 'calculus-grapher-1.0' branch.

To verify in the next RC, repeat memory testing and compare to the results for the previous RC that are shown in phetsims/qa#924 (comment).

@KatieWoe
Copy link

Memory looks ok to me.
cgmem

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

No branches or pull requests

3 participants