A memory leak reading/processing histos in *.root files?


I have written a root macro (att. 1) that opens an input *.root
file, extracts some info from TH1 histograms and fills different
TH1 histograms and then, in a “for” loop, repeats the process
for the next input *.root file. When last *.root file is processed,
loop is finished and new filled histograms are written into one
new output *.root file.

This code works for several dozen input *.root files, but when
I loop over several hundred input files, the code comes to
a standstill. I assume that I have a memory leak, but I cannot
see a problem in my code (given my humble knowledge of C++;8-).

I was hoping that “delete”-ing all file and TH1 pointers would
solve the problem, but that did not help.

What elementary C++ mistake I am making?

                                                                   TIA, Emil

example.C (4.53 KB)

see my answer to your other mail. Problem is likely related.