pyhf: Memory leak or at least excessive memory consumption
Description
I noticed a big memory hog when running a certain number of iterations of pyhf.infer.hypotest
. This strange behaviour has been confirmed with a small code that repeatedly executes hypotest
.
A similar behavior has been noticed when switching backends.
Expected Behavior
Memory profile should be constant when using pyhf.infer.hypotest
or switching backends.
Actual Behavior
The following behavior was observed by using the python memory_profile
library :
- When running
pyhf.infer.hypotest
10000 times in a row, memory consumption is constantly growing. - Similarly, when switching backends with
pyhf.set_backend()
repeatedly, an anomalous memory consumption can be observed.
Steps to Reproduce
pyhf version 0.4.1 was used. In attachment, you can find the following files :
memPyhf.py
: a code that executespyhf.infer.hypotest
10000 times in a row using a simple json definitionmprofile_hypotest.dat
: the memory profile ofmemPyhf.py
(made withmprof run memPyhf.py
)switchBackends.py
: a code that switches backends a 1000 times in a rowmprofile_switchBackends.dat
: memory profile ofswitchBackends.py
The memory profiles can be reproduced by running mprof run memPyhf.py
or mprof run switchBackends.py
with the two python scripts.
Checklist
- Run
git fetch
to get the most up to date version ofmaster
- Searched through existing Issues to confirm this is not a duplicate issue
- Filled out the Description, Expected Behavior, Actual Behavior, and Steps to Reproduce sections above or have edited/removed them in a way that fully describes the issue
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25 (16 by maintainers)
I’m testing right now on a big run and memory usage didn’t increase after several minutes so it seems to be fixed. Thanks a lot!
Hi all,
I’ve tested the code snippet that repeatedly executes
hypotest
withv0.5.1
and there is no memory leak anymore. However, we still have a memory leak in ourSModelS/pyhf
interface, but then the problem must lie somewhere in our interface.Thanks for the help!