SetBinLabel causes memory leak?

Dear ROOTers,

We have been experiencing memory leak in our realtime display software. We have a consumer program that is reading the TMapfile continously and display the histograms. To avoid memory leak, I used a dumb approach by deleting the histogram after each read. However the leak does not go away. The origin of the problem seems to be related to the alphanumeric labels of the histograms. Please run the attached small scripts, which illustrated the problem. As long as one comments out the “SetBinLabel” lines, no leak is observed. Is there a simple fix?

We are using ROOT 5.08 compiled with gcc-3.2.3 on Red Hat Enterprise Linux. I tried the program with an older ROOT (4.00-08) and found the same behavior.

Thanks much for any help you could offer!

Jianglai
binlabel.tar.gz (4.26 KB)

Thanks for reporting this memory leak. Now fixed in the CVS head.
Note that your test program had a seg violation.
See correct version below

Rene

[code]{
TH1F *htest = NULL;
const char *sCerLabel[4] = {“PMT1”,“PMT2”,“PMT3”,“PMT4”};

for(size_t i=0; i<10000; i++){

htest = new TH1F("htest","htest",4,0,4);
    
for(size_t i=0;i<4;i++){
  htest->GetXaxis()->SetBinLabel(i+1, sCerLabel[i]);
}

delete htest;

}
printf(“Done with the test\n”);
return 0;
}
[/code]