Greetings,
I am using mallocdebug on Mac OS X 10.4.10 / ROOT 5.14 in order to seek the remaining memory leaks in my code.
mallocdebug reports that I am almost systematically leaking 20 bytes of memory on calls to TH1I::Fit, an operation which I am doing very frequently.
I have narrowed down the offending code to a small testcase:
#include "TH1.h"
#include "TF1.h"
#include "TCanvas.h"
#include "TApplication.h"
int main(int argc, char** argv) {
TApplication app("app", &argc, argv);
TH1I *hist = new TH1I("histogram","histogram",11,0,11);
hist->Fill(5);
TF1* fitfunc;
fitfunc = new TF1("fitfunc","gaus", 3, 7);
fitfunc->SetParameter(1, 5);
hist->Fit("fitfunc", "R0Q");
//TCanvas* canvas = new TCanvas();
app.Run();
}
This is particularly weird. When the call to TCanvas is commented, the leak does not occur. When it is uncommented, the leak occurs. mallocdebug traces the leaked buffer back to TH1::Fit(TF1*, char const*, char const*, double, double) -> TF1::Copy(TObject&) -> TFormula::Copy(TObject&) -> operator new[] -> operator new.
Could this be a erroneous report from mallocdebug caused by an incorrect use of the tool, which seems more tailored to find leaks in Apple Obj-C frameworks ?
Thanks a lot for your help.