Root still eating memory, please help

Hi,

I have a class in which I use a TH1F object all the time again and again, and the result is that somehow the memory of my pc just gets more less as it runs. I Fill the TH1F in a loop a lot of time and I need to empty it and reuse again. I don’t understand why it eats more and more memory when I declare my TH1F histo in the header of my class and I construct it in the constructor of my class and delelte it in the destructor. The only thing that happens is that I ‘empty’ the histo in this way:

histo->Add(histo, -1);

which is - I think - a bad solution for using the same histo a million times. So can you give a better solution for using the same histo a miilion times and without eating all my 512 Mbyte memory?

The usual way:

TH1F * histo = (TH1F*)gROOT->FindObject(“histo”);
if(histo) delete histo;
histo = new TH1F(“histo”,“histo”, 100, 0, 100);

inside the loop, doesn’t work unfortunately.

Thanx in advance,

Balint

Hi,

We do not have enough information to be able to determine what the problem is :frowning: A concrete working example reproducing the issue would help a lot :slight_smile:.

Cheers,
Philippe.

Cross posting. It was solved here already: http://root.cern.ch/phpBB2/viewtopic.php?t=1961
Axel.