TH1::Fit memory leaks

Hi there,

I’m experiencing memory leaks with TH1::Fit in Root_5.21.04.
Here’s the isolated glitch :

Int_t nLoops = 10 ; Int_t nBins = 250000 ; TH1F *h1 = new TH1F ("h1","h1", nBins,0,nBins) ; for (Int_t bin=1;bin<=nBins;bin++) { h1->SetBinContent(bin,10.+gRandom->Uniform()) ; } TF1 *fct = NULL ; for (Int_t i=0;i<=nLoops;i++) { fct = new TF1 ("fct","pol1",0,nBins) ; h1->Fit("fct","RQ0") ; delete fct ; fct = NULL ; }
The memory allocated to Root just gets higher and higher.
Using the “h1->GetFunction(“fct”)” trick from post does not work.
Using Root_5.20.00 (as suggested in solves the problem!
When using “gObjectTable->Print()” with 2 different values for nLoops, namely 10 and 100, the only difference lies in TBackCompFitter! (I get a factor of 10)
Any clue ?

Thanks in advance,


Thank you for reporting this. There is a bug in the destructor of the
TVirtualFitter. I will now fix in the ROOT svn.
This leak was happening only when using the linear fitter.
If you use Minuit (option “F”), the leak should not be there.

Best Regards