Potential TF1Convolution memory leak

Dear all,

I believe I found a memory leak within the TF1Convolution class, or perhaps the way I’m using it is simply wrong.

This is related also to this thread: Memory increase in repeated fits using TF1Convolution

I see exactly the same behavior. I created a minimal working example to execute TF1Convolution on a loop:

#include <TF1.h>
#include <TF1Convolution.h>

double test_convolution_function(double *x, double *p);

void test_TF1Convolved(){
	TF1 *f1 = new TF1("f1", test_convolution_function, -1, 6, 0);
	while(true) f1->Eval(1.);
}

double test_convolution_function(double *x, double *p) {

	TF1Convolution f_conv("expo", "gaus", -1, 6, true);
	f_conv.SetRange(-1., 6.);
	f_conv.SetNofPointsFFT(40000);

	TF1 f("f", f_conv, 0., 5., f_conv.GetNpar());
	f.SetParameters(1., -0.3, 0., 1.);

	return f.Eval(x[0]);
}

Within this JIRA issue the claim is that it was solved: https://sft.its.cern.ch/jira/browse/ROOT-9361

But I just tested today root v6-13-02 and the problem persists (also with v6-12-06).

I’m running on Ubuntu 16.04 with gcc 4.8.

Am I using the wrong ROOT version? Or is the problem really still there?

Thank you in advance!

Hi,

The issue has been fixed in 6.13.03 and in 6.12 patches, 6.12.07. The version you have tested are just the one before and still contain the bug

Cheers

Lorenzo

Oh, I assumed the fix would be contained within v6-13-02. I will test the gitHub master and confirm it here.

Thank you Lorenzo!

Dear Lorenzo,

I just tested the github master version and the memory leak is indeed reduced, but not removed (executing the code I copy-pasted above).

But modifying it slightly, as shown below, the memory leak disappears:

#include <TF1.h>
#include <TF1Convolution.h>

double test_convolution_function(double *x, double *p);

void test_TF1Convolved(){
	TF1 *f1 = new TF1("f1", test_convolution_function, -1, 6, 0);
	while(true) f1->Eval(1.);
}

TF1Convolution* f_conv;
double test_convolution_function(double *x, double *p) {

	if (f_conv) delete f_conv;
	f_conv = new TF1Convolution("expo", "gaus", -1, 6, true);
	f_conv->SetRange(-1., 6.);
	f_conv->SetNofPointsFFT(40000);

	TF1 f("f", f_conv, 0., 5., f_conv->GetNpar());
	f.SetParameters(1., -0.3, 0., 1.);
	return f.Eval(x[0]);
}

I’m not sure why there is such a leak in the code above, but I assume that is my lack of knowledge.

Thank you for the help!

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