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

Memory leak when disposing fuse node. #499

Closed
Denz1994 opened this issue May 21, 2019 · 6 comments
Closed

Memory leak when disposing fuse node. #499

Denz1994 opened this issue May 21, 2019 · 6 comments

Comments

@Denz1994
Copy link
Contributor

Found during #495.

Using Chrome (incognito) I followed these steps on the Lab Screen:

  1. Take heap snapshot
  2. Drag out max amount (10) of fuses in the play area (making sure not to connect them)
  3. Take heap snapshot
  4. Click trash can button for each fuse in the play area to dispose of them until none were left.
  5. Take heap snapshot

Comparing the initial snapshot to the last one produced a memory increase of about 10 mb over 50 fuse disposals. Results are posted below.

Similar results were recorded for dragging the fuses into the carousel for disposal. @samreid Thought this is something worth looking into. Assigning to @samreid for further investigation.

Heap snapshot comparing initial play area with final play area after 50 disposals. Here we see a delta of +10 Fuse and +10 ResetFuseButton objects. Note there is a duplicate 16th snapshot as a sanity check.
image

@samreid
Copy link
Member

samreid commented Jun 27, 2019

Same problem for resistors. Dragging out 10 resistors then pressing reset all shows 10 resistors still in memory.

@samreid
Copy link
Member

samreid commented Jun 27, 2019

A few minutes of fuzzing:
image

@jessegreenberg
Copy link
Contributor

After phetsims/scenery#982, here are a collection of heap snapshots with ?fuzz in CCK-DC, taken every 30-45 seconds.
image

@samreid
Copy link
Member

samreid commented Jun 28, 2019

The wide variability is due to creation and deletion of components. A less noisy test would be to press Reset All right before each memory snapshot, but currently we have no way to do that during fuzzing. Here are my results from a run:

image

@samreid
Copy link
Member

samreid commented Jun 29, 2019

I launched the sim with ?fuzz, then captured a memory profile, then let it run for a few minutes, then paused fuzzing via phet.chipper.queryParameters.fuzz=false then captured another memory profile. No problems indicated between the two snapshots.

image

Following @Denz1994 instructions from the top comment, I still see an allocation for the first Fuse/FuseNode but after that, subsequent creation/deletion do not appear. Perhaps the first one is just some startup overhead? I followed these steps:

  1. Launch sim.
  2. Create one fuse and dispose it with "erase button"
  3. Capture memory profile
  4. Create 3 fuses then delete each with the erase buttons
  5. Capture memory profile.

I saw no fuse deltas for this use case:
image

@Denz1994 can you please review? Close if all is well.

@Denz1994
Copy link
Contributor Author

Denz1994 commented Jul 2, 2019

Thanks, @jessegreenberg for the help on this one. I'm seeing similar results after repeating @samreid test from #499 (comment).

I'm going to close this one since the initial memory leak is not evident any longer in the memory profiles.

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