-
Notifications
You must be signed in to change notification settings - Fork 3
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
Memory leak #153
Comments
... and in phetsims/qa#1067 (comment) for graphing-slope-intercept by @KatieWoe: Similar to phetsims/qa#1066, this sim has a large memory leak |
I've identified a couple of common-code leaks -- NumberPicker is probably the largest contributor in this sim. But I suspect that most of the leaks are due to disposed elements that are not unlinking from LocalizedStringProperty and ProfileColorProperty. |
I added this to ProfileColorProperty: public override link( listener: PropertyLinkListener<Color>, options?: LinkOptions ): void {
if ( this.tinyProperty.listeners.size > 25 ) {
debugger;
}
super.link( listener, options );
} And I added this to LocalizedStringProperty: public override link( listener: PropertyLinkListener<string>, options?: LinkOptions ): void {
if ( this.tinyProperty.listeners.size > 100 ) {
debugger;
}
super.link( listener, options );
} Fuzz tested, and discovered a leak in AccessibleNumberSpinner (see phetsims/sun#879) and a few more sim-specific leaks (fixed in e6a8bbf). I tested with this uncommitted patch to AccessibleNumberSpinner: Subject: [PATCH] various memory leaks related to LocalizedStringProperty and ProfileColorProperty, https://github.com/phetsims/graphing-lines/issues/153
---
Index: js/accessibility/AccessibleNumberSpinner.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/accessibility/AccessibleNumberSpinner.ts b/js/accessibility/AccessibleNumberSpinner.ts
--- a/js/accessibility/AccessibleNumberSpinner.ts (revision 75e22745c05481d1d6b3e80c8d7d2138563df27a)
+++ b/js/accessibility/AccessibleNumberSpinner.ts (date 1712621584033)
@@ -180,6 +180,7 @@
this.pdomDecrementDownEmitter.dispose();
this.removeInputListener( accessibleInputListener );
+ this.removePDOMAttribute( 'aria-roledescription' );
};
} Heap size is much better, but it does not yet stabilize or go down: |
I identified a few more things that were observing Line.color, which is TColor and may therefore be a Property. Heap size now stabilizes at ~102 MB for graphing-lines:
Next is to cherry pick the sim-specific and common-code commits added above. |
Here's what needs to be cherry picked so far, from above commits. scenery-phet sun graphing-lines |
(cherry picked from commit e3797d4)
…graphing-lines#153 (cherry picked from commit 75e2274)
(cherry picked from commit e3797d4)
…graphing-lines#153 (cherry picked from commit 75e2274)
In phetsims/sun#879 (comment), @jessegreenberg noted:
Ugh. I see that RichDragListener needs to be disposed because it owns 2 SoundClips that are added to soundManager. And this sim has 6 subclasses of RichDragListener. The game reward (GLRewardNode) also looks like its leaking, because some of the rewards are linked to LocalizedStringProperty (eg "x" and "y" in the equations). I'll tackle those next. |
Over in phetsims/sun#879, I confirmed that there's nothing wrong with disposal of AccessibleNumberSpinner, so no changes forthcoming for that. After the above disposal of RichDragListener and GLRewardNode, there's more improvement. I tested with unbuilt, heap snapshots at 1-minute intervals, 10 minutes between snapshots 10 & 11. http://localhost:8080/graphing-lines/graphing-lines_en.html?brand=phet&ea&fuzz&debugger http://localhost:8080/graphing-slope-intercept/graphing-slope-intercept_en.html?brand=phet&ea&fuzz&debugger |
Cherry picks for RichDragListener and GLRewardNode leaks were done above. This is ready for testing in the next RC. |
Ready for review in GL 1.4.0-rc2 and GSI 1.2.0-rc2. Please close this issue if it tests OK. Below are my tests for the RC2 built versions. I took a heap snapshot every 1 minute, until the heap sized stabilized. https://phet-dev.colorado.edu/html/graphing-lines/1.4.0-rc.2/phet/graphing-lines_en_phet.html?fuzz https://phet-dev.colorado.edu/html/graphing-slope-intercept/1.2.0-rc.2/phet/graphing-slope-intercept_en_phet.html?fuzz |
Reported in phetsims/qa#1066 (comment) for graphing-lines by @KatieWoe:
The text was updated successfully, but these errors were encountered: