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.hypotest10000 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.hypotest10000 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 fetchto 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
hypotestwithv0.5.1and there is no memory leak anymore. However, we still have a memory leak in ourSModelS/pyhfinterface, but then the problem must lie somewhere in our interface.Thanks for the help!