phetsims / greenhouse-effect

"Greenhouse Effect" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
4 stars 4 forks source link

Test for memory leaks as part of code review #327

Closed jbphet closed 11 months ago

jbphet commented 11 months ago

The code is being reviewed for this sim prior to releasing the phet-io version. This issue is where the results of the memory leak testing for both the phet and phet-io brands will be recorded.

jbphet commented 11 months ago

The dev version that I'll use for memory leak testing is https://phet-dev.colorado.edu/html/greenhouse-effect/1.2.0-dev.1/phet/greenhouse-effect_all_phet.html.

jbphet commented 11 months ago

The memory leak test looks good, see the screenshot below. I followed the standard procedure, so snapshot 1 is after loading the sim normally (no fuzz, no interaction). Snapshot 2 was taken after 1 minute of fuzz testing, snapshot 3 after 2 minutes, and so forth through snapshot 11. Snapshot 12 was taken 10 minutes after snapshot 11, and 13 was 10 minutes after that. The memory usage appears to stabilize at a value around 83MB, which is reasonable. I think we're good here. Closing.

image

jbphet commented 11 months ago

Reopening. I was just going through the code review checklist and realized this test needs to be done in Studio as well to verify that the sim isn't leaking phet-io objects.

jbphet commented 11 months ago

Phet-io memory testing using colorized data stream.

Local link: http://localhost:8080/greenhouse-effect/greenhouse-effect_en.html?brand=phet-io&phetioConsoleLog=colorized&phetioStandalone&phetioEmitHighFrequencyEvents=false&locales=*&keyboardLocaleSwitcher&ea&debugger&fuzz

This test was a bit problematic because the developer tools kept closing by themselves every 4 minutes or so, probably because they were getting overwhelmed by the amount of data being output to the console. The heap snapshot history was lost each time this happened. So, I ran the test and wrote down the memory numbers, and put it in the table below. It looks like there is no leak, and the memory usage tops out at 120 MB, which is definitely higher than the non-phet-io case, but still, I believe, acceptable.

Time (minutes) Memory Usage (MB)
0 73.3
1 112
2 117
3 117
4 119
5 119
6 119
7 120
8 120
9 120
10 120
jbphet commented 11 months ago

Phet-io memory test in studio, local link = http://localhost:8080/studio/?sim=greenhouse-effect&locales=*&keyboardLocaleSwitcher&phetioWrapperDebug=true&phetioElementsDisplay=all&fuzz

No leak detected, memory usage stabilizes around 146 MB.

Time (minutes) Memory Usage (MB)
0 101
1 138
2 144
3 144
4 143
5 145
6 143
7 143
8 144
9 146
10 146
20 146
jbphet commented 11 months ago

No leaks detected, closing.