Memory increase in repeated fits using TF1Convolution

Please provide the following information:

ROOT Version (e.g. 6.12/02): 6.10/04
Platform, compiler (e.g. CentOS 7.3, gcc6.2): SLC6, gcc6.2

I have to perform fits many times over in my code. The fit function that I use is a convolution of two functions, constructed as in this tutorial:

But I notice that the memory usage by ROOT increases quite linearly with running time, while the fits are being iterated over. In my case, I iterate until the computer runs out of memory and the program gets killed. You can reproduce this by looping over the fit in the above tutorial code many times as well.

If I making an elementary mistake in memory management here, could I get some help? Or might this be a problem with ROOT?

Thank you.

#include <stdio.h>
#include <TMath.h>
#include <TCanvas.h>
#include <iostream>
#include <TROOT.h>
#include <TChain.h>
#include <TObject.h>
#include <TRandom.h>
#include <TFile.h>
#include <math.h>
#include <TF1Convolution.h>
#include <TF1.h>
#include <TH1F.h>
#include <TGraph.h>
#include <TStopwatch.h>
using namespace std;
void fitConvolution()
   // generate histogram
   TH1F *h_ExpGauss = new TH1F("h_ExpGauss","Exponential convoluted by gaussian",100,0.,5.);
   for (int i=0;i<1e6;i++)
      Double_t x = gRandom->Exp(1./0.3);//gives a alpha of -0.3 in the exp
      x += gRandom->Gaus(0.,3.);
      h_ExpGauss->Fill(x);//probability density function of the addition of two variables is the convolution of 2 dens. functions
   // make convolution function
   TF1Convolution *f_conv = new TF1Convolution("expo","gaus",-1,6,true);
   TF1   *f = new TF1("f",*f_conv, 0., 5., f_conv->GetNpar());
   // fit many times
   for (int i=0 ; i<1000 ; i++) {

Do you mean that you call the “fitConvolution” function many times?


No, I mean the for loop in the code - the TH1F and TF1Convolution pointers are made once. and the call hist->Fit(function) is being called many times over (1000 times in the example). I can see the memory usage by root increase while the fit is being repeated.

This is Ubuntu 14.04.5 LTS / x86_64 with gcc 4.8.4 here. I can confirm that I also see this problem with ROOT 6.08/06, 6.10/08 and 6.12/06.


This is a bug, can you please open a new bug issue in JIRA ?
Thank you for reporting this problem


I’ve filed a JIRA issue here:

Thank you

Thank you very much ! I will investigate as soon as possible !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.