phetsims / atomic-interactions

"Atomic Interactions" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
1 stars 2 forks source link

Bad Memory Leak #72

Closed KatieWoe closed 5 years ago

KatieWoe commented 6 years ago

For https://github.com/phetsims/QA/issues/216 Start: 17.5 MB 1 min: 128 MB 2 min: 231 MB 3 min: 334 MB 4 min: 441 MB 5 min: crash before heap snapshot can finish. Will try test on published version per request of @jbphet

KatieWoe commented 6 years ago

With published version: Start: 13 MB 1 min: 14.8 MB 2 min: 15.5 MB 3 min: 15.9 MB 4 min: 16.1 MB 5 min: 16.5 MB

KatieWoe commented 6 years ago

@jbphet requested the test be done on recently published States of Matter. Start: 27.2 1 min: 56.6 2 min: 74.9 3 min: 94.2 4 min: 119 5 min: 137

jbphet commented 6 years ago

I did a memory analysis and found the leaks. There were three nodes for which there were no dispose functions, so they have been added. Kinda a lame of me to have missed these, but it's great that QA ran this test and identified the problem.

Running a RequireJS version of Atomic Interactions, I now see the following memory heap size:

Time (minutes) Memory Usage (MB)
0 17.3
1 22.6
2 22.8
3 24.5
4 25.3
5 25.6
6 25.5
7 25.7
8 26.0
9 26.2
10 26.2

This is a pretty reasonable profile. The memory is increasing very gradually, and decreases between minutes 5 and 6, and holds steady between minutes 9 and 10. I did some comparisons between the heap snapshots, and there was nothing obvious from the sim that was leaking. If there is a slow leak, it's probably somewhere in common code, and it's not enough to cause any problems.

Bottom line: I think this is now fixed.