Hello,
I have recently noticed a rather large memory usage associated with a script that I have written. The basic idea is that I generate a RooSimultaneous composed of 2D PDFs in (x,y). I then fit this RooSimultaneous to data (from a RooMCStudy) saving the result to a RooFitResult. Next I delete the RooSimultaneous, pull out the minNll() associated with the fit, and delete the RooFitResult. The problem is that after this is done I have a few parameters leftover in memory called “params”. Since I am doing this fit hundreds of times at different locations in my 2D space this leads to a very noticeable memory management issue. I’ve done a memory trace on the script and here is what I have come up with:
Objects allocated before creating my RooSimultaneous (0 objects):
Objects allocated after RooSimultaneous creation, but before fit:
List of RooFit objects allocated while trace active:
0x21a09f0 : RooSimultaneous - NullPdf
0x21a0e90 : RooSetProxy - !plotCoefNormSet
0x21974e0 : RooRealVar - nevents_1
0x21d7350 : RooRealVarSharedProperties - RooRealVarSharedProperties
0x218b150 : RooExtendPdf - exNullModel_1
0x7f0e4e682d54 : RooArgSet - owned components
0x7f0e4e682ed4 : RooArgSet - owned components
Objects allocated after RooSimultaneous fit to data:
List of RooFit objects allocated while trace active:
0x21a09f0 : RooSimultaneous - NullPdf
0x21a0e90 : RooSetProxy - !plotCoefNormSet
0x21974e0 : RooRealVar - nevents_1
0x21d7350 : RooRealVarSharedProperties - RooRealVarSharedProperties
0x218b150 : RooExtendPdf - exNullModel_1
0x7f0e4e682d54 : RooArgSet - owned components
0x7f0e4e682ed4 : RooArgSet - owned components
0x7f0e4e6843d4 : RooArgSet - params
0x7f0e4e684f14 : RooArgSet - params
0x7f0e4e685754 : RooArgSet - params
0x21848e0 : RooArgList -
0x1bb2a00 : RooArgList -
0x218d5d0 : RooRealVar - nevents_1
0x217e5e0 : RooArgList -
0x217e750 : RooRealVar - nevents_1
Objects allocated after RooSimultaneous delete:
List of RooFit objects allocated while trace active:
0x21d7350 : RooRealVarSharedProperties - RooRealVarSharedProperties
0x7f0e4e6843d4 : RooArgSet - params
0x7f0e4e684f14 : RooArgSet - params
0x7f0e4e685754 : RooArgSet - params
0x21848e0 : RooArgList -
0x1bb2a00 : RooArgList -
0x218d5d0 : RooRealVar - nevents_1
0x217e5e0 : RooArgList -
0x217e750 : RooRealVar - nevents_1
Objects allocated after RooFitResult delete;
0x21d7350 : RooRealVarSharedProperties - RooRealVarSharedProperties
0x7f0e4e6843d4 : RooArgSet - params
0x7f0e4e684f14 : RooArgSet - params
0x7f0e4e685754 : RooArgSet - params
So it looks like whatever variable “params” is, its not being deleted properly. Its not a variable that I am creating, but looks like it is being created in the process of the actual fit so I’m not sure how I have any control over its existence. If it’s any help, I’m doing my fit with the following commands:
RooFitResult *NullFitResult = NullPdf->fitTo(*data, Save(1), Range(*model.rangeName),
PrintLevel(-1), SumW2Error(kFALSE), Strategy(0), Optimize(1));
I’ve tried with Strategy= 1 & 2 with similar results. Optimize= 0 seems to result in only 2 instances of “params”, but that doesnt solve the overall problem. My guess is that the issue is connected to how the fit does constant optimization, but after a couple hours trying to find where this occurs I’m hoping there’s a simpler solution. If it would help, let me know and I can put together a simple example of what I’m doing and post it.
Thanks for any help you can give!