How can I avoid memory leaks in this situation?

I produce several simulations with Pythia and store the results in several histograms.

I want to compare the results of the simulation using different Pythia settings, so I began writting a program that would take as inputs the root files with my results.

The problem is that since the root files were all created by exactly the same program (only the Pythia settings change) all things inside have exactly the same names, which means that I would have one of those “Potential memory leaks”.

The obvious solution is to change the code before each simulation so that the results have different names, but you can see how that’s cumbersome, I want the process to be as automatic as possible.

Is there a way I could go around this problem?.


What language are you writing your program in? You could certainly handle this in c++ fairly simply using an std::map. Could you post some example code?

Just call TH1::AddDirectory(kFALSE); in the beginning of your code.


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