I am using pyROOT within the CMS framework, and it does a great job
However, when I read a series of trees in different files (~30 files, 20k events each),
I see the the memory usage increasing continuously. This goes on until
at some point the interpreter crashes with error messages like
or errors about reading the root file. I suspect this might be a memory
leak, but I do not know how to investigate it; I tried simply to monitor
the garbage collector:
and I see that this is increasing as well.
The code looks like:
from ROOT import * from cmstools import * import os gSystem.Load("libFWCoreFWLite.so") AutoLibraryLoader.enable() for phi in phi_s[:-1] : for eta in eta_s : <...> fileSim = TFile.Open(fname) #get the tree simEvents = fileSim.Get("Events") nSimEvents = simEvents.GetEntries() # read the branches hcalSimHitBranch = simEvents.GetBranch("PCaloHits_g4SimHits_HcalHits_T.obj") hcalSimHit = std.vector(PCaloHit)() hcalSimHitBranch.SetAddress(hcalSimHit) for ev in range(nEvents): hcalSimHitBranch.GetEntry(ev) for simHit in all(hcalSimHit): <do> fileSim.Close()
The code works perfectly fine when I run on few (~1k) events per file, but
gives problems when running on more events (this seems to be a clear hint
to an eventual memory leak…).
Please, could you give me any suggestion about how I could debug this? Did anyone experience anything like this when reading a large number of events with pyROOT ?
Thank you very much in advance,