Skip to content

[RF] RooFit for loop fitTo explodes in memory usage #6975

@lan13005

Description

@lan13005
  • Checked for duplicates

Describe the bug

Everytime I call fitTo there seems to be various roofit objects that are created and are not cleaned after every iteration. I cannot get RooTrace::dump() to output anything but I am able to use RooTrace::printObjectCounts() to output the object counts. It seems fitTo creates a bunch of RooAbsCollection objects that are not cleaned which starts to consume all the memory. I can see the resident memory usage go up when looking at the top command.

Expected behavior

Well, ideally, I hope that I would be able to call fitTo all the times I would like

To Reproduce

I will include it here since it is really short program

void test(){

    RooTrace::active(kTRUE);
    RooTrace::mark();
    RooRealVar x("x","x",-10,10);
    RooDataSet d("d","d",RooArgSet(x));
    RooRealVar s("s","s",1,1,10);
    RooRealVar m("m","m",0,-10,10);
    RooGaussian g("gauss","gauss(x,m,s)",x,m,s);
    RooPlot *f=x.frame();
    for (Int_t j=0; j<300; ++j){
        x.setVal(gRandom->Gaus(0,1));
        d.add(x);
    }
    for (Int_t i=0; i<10; i++) {
        cout << "\n------------------------------\nStart iteration " << i << endl;

        cout << "Before fitting" << endl;
        RooTrace::printObjectCounts();

        g.fitTo(d,RooFit::PrintLevel(-1));//,RooFit::SumW2Error(true),RooFit::BatchMode(true));
        cout << "After fitting" << endl;
        RooTrace::printObjectCounts();
     }
}

Setup

Have tried root 6.08/ 6.23 on CentOS 7. Built the root distros

Additional context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions