-
Notifications
You must be signed in to change notification settings - Fork 950
Closed
coursier/sbt-coursier
#563Labels
Description
steps
- Clone https://github.com/mrdziuban/sbt-update-memory-leak
cd
into it- Run a couple commands:
# Run 10 updates, then 50 updates ./run.sh 10 ./run.sh 50
- Open the heap dumps that were output to the
heap-dumps
directory. You can either use Eclipse Memory Analyzer or VisualVM- Using Eclipse Memory Analyzer
- Click File > Open Heap Dump...
- Navigate to
/path/to/sbt-update-memory-leak/heap-dumps
- Open
sbt-10-updates.hprof
- Under "Actions" click on "Dominator Tree"
- Look for the row where the Class Name is
class lmcoursier.internal.SbtUpdateReport$
and take note of the Retained Heap value - Repeat steps a-e, but this time opening
sbt-50-updates.hprof
- Using VisualVM
- Click File > Load...
- Navigate to
/path/to/sbt-update-memory-leak/heap-dumps
- Open
sbt-10-updates.hprof
- Under "Dominators by Retained Size" click "Compute Retained Sizes" and wait for it to complete
- Next to "Dominators by Retained Size" click "view all"
- Look for the row where the Name is
class lmcoursier.internal.SbtUpdateReport$
and take note of the Retained value - Repeat steps a-f, but this time opening
sbt-50-updates.hprof
- Using Eclipse Memory Analyzer
- Calculate the difference between the retained heap after 10 updates vs. after 50 updates -- you'll see that after 50 updates, there is ~5x more retained heap
problem
The retained heap size of lmcoursier.internal.SbtUpdateReport$
grows linearly with the number of times update
is run. On my laptop I ran run.sh
with values of 10, 20, 50, 100, and 500. The retained heap of lmcoursier.internal.SbtUpdateReport$
for each was:
Number of update s |
Retained heap | Δ from 10 update s |
---|---|---|
10 | 5,317,936 bytes | -- |
20 | 10,685,776 bytes | 2.01x |
50 | 26,775,392 bytes | 5.03x |
100 | 53,600,336 bytes | 10.08x |
500 | 268,214,744 bytes | 50.44x |
expectation
The retained heap of lmcoursier.internal.SbtUpdateReport$
should remain fairly consistent with the number of update
s that are run. Better yet, whatever it's currently retaining could be garbage collected.
notes
The linked repository also includes a script to show that enough update
s will eventually cause an out of memory error. You can run it with
./oom.sh