Open samreid opened 1 month ago
Switching back and forth between single block and 2x blocks in density intro screen looks like a leak. I switched back and forth 7x times, and check out all the multiples of 7 in the delta column:
Experimental patch. Corrects one leak, but that one was masking another leak:
@jessegreenberg and @zepumph identified an issue that was leading to this symptom. @jessegreenberg is taking next steps on that, and I will resume investigation for more sim-specific problems after that is committed
The fix for this has been committed in https://github.com/phetsims/scenery/issues/1637 and is awaiting review. @samreid would you like to verify?
I can see that elements like HTMLDivElement are no longer being leaked after the fix above. I see plenty of other leaks that may not be related to https://github.com/phetsims/scenery/issues/1637 so I will continue to investigate here.
Here are the "7x" leaks in the latest test:
KeyboardListener has a memory leak when registering to passed-in enabledProperty instances like in
const keyboardDragListener = new KeyboardDragListener( {
// In model units per second
dragSpeed: 3,
shiftDragSpeed: 0.5,
// This is needed for keyboard but not for mouse/touch because keyboard input applies deltas, not absolute positions
transform: INVERT_Y_TRANSFORM,
drag: ( event, listener ) => {
mass.updateDrag( mass.matrix.translation.add( listener.modelDelta ) );
},
enabledProperty: mass.inputEnabledProperty,
tandem: Tandem.OPT_OUT
} );
After the fixes above, density screen 1 memory testing tapers off after about 15 minutes:
The above fix makes so much sense. I was really confused about your report in https://github.com/phetsims/density-buoyancy-common/issues/168#issuecomment-2158981435, because when working with you and JG sync on https://github.com/phetsims/scenery/issues/1637, we didn't see any other leaks in the area. Then I added the enabledProperty for phet-io support in https://github.com/phetsims/density-buoyancy-common/commit/ffbcd5b16cd9e8442b83620be693bcbbf83162d4 and likely caused this all over again. Thanks for investigating. It is a good reminder that despite the work we do here, we will want to do a memory test as part of RC as well (which I think is already done by QA, just noting here for completeness).
Next we have a leak related to touches being saved by buttons. Here is the memory trace for buoyancy all screens fuzzing:
// 3:04pm 189MB
//3:10pm 195MB
//3:13pm 224MB
//3:17pm 256MB
At least one leak seems related to the startEvent
which was introduced in https://github.com/phetsims/sun/issues/858
It looks like density has a memory leak:
density fuzzing unbuilt with assertions
6:26am 115MB 6:28am 129MB 6:30am 134MB 6:32am 140MB