RooFit/RooStats leaks memory when reading out RooFitResult and HypoTestInverterResults from disk.
The leaks notably already occur when doing something simple like opening a file, retrieving a RooFitResult or HypoTestInverterResult, deleting that, and then closing the file. This caused writing the CLs values of some SUSY optimisation results (30 models, ~8000 SRs) to JSON files to use 50GB not even half-way through.
The easiest way to test it is to create a file with 1 result in it and then running a simply script like below in Valgrind, or just monitoring the memory usage in top:
We have attached a patch that addresses this issue.
The RooFitResult class forgot to all a static function to RooAbsArg (RooWorkspace's streamer did this correctly). The patch for HypoTestInverterResult ensures it owns its internal HypoTestResults and SamplingDistributions. If it doesn't, the two TLists leak memory. Also, some getters were improved.
It would be nice to change HypoTestInverterResult internally to return shared_ptrs or const HypoTestResult& from these getters (and not HypoTestResult*) as these are much less prone to accidentally exposing too much of the class, but this might break other things so we didn't do that.
Geert-Jan Besjes & Ingrid Deigaard