python - Huge memory usage in pyROOT -


my pyroot analysis code using huge amounts of memory. have reduced problem example code below:

from root import tchain, th1d  # load file, chain chain = tchain("somechain") infile = "somefile.root" chain.add(infile)  nentries = chain.getentries()  # declare histograms h_ntracks = th1d("h_ntracks", "h_ntracks", 16, -0.5, 15.5) h_e = th1d("h_e","h_e",100,-0.1,6.0) h_p = th1d("h_p", "h_p", 100, -0.1, 6.0) h_eclenergy = th1d("h_eclenergy","h_eclenergy",100,-0.1,14.0)  # loop on entries jentry in range(nentries):    # load entry    entry = chain.getentry(jentry)     # define variables    cands = chain.__ncandidates__    ntracks = chain.ntracks    e = chain.usecmsframe__boe__bc    p = chain.usecmsframe__bop__bc    eclenergy = chain.usecmsframe__boeclenergy__bc     # fill histos    h_ntracks.fill(ntracks)    h_eclenergy.fill(eclenergy)     cand in range(cands):       h_e.fill(e[cand])       h_p.fill(p[cand]) 

where somefile.root root file 700,000 entries , multiple particle candidates per entry.

when run script uses ~600 mb of memory. if remove line

h_p.fill(p[cand]) 

it uses ~400 mb.

if remove line

h_e.fill(e[cand]) 

it uses ~150 mb.

if remove lines

h_ntracks.fill(ntracks) h_eclenergy.fill(eclenergy) 

there no further reduction in memory usage.

it seems every histogram fill of form

h_variable.fill(variable[cand]) 

(i.e. histograms filled once per candidate per entry, opposed histograms filled once per entry) use ~200 mb of memory. becomes serious problem when have 10 or more histograms because using gbs of memory , exceeding limits of computing system. have solution?

update: think python3 problem.

if take script in original post (above) , run using python2 memory usage ~200 mb, compared ~600 mb python3. if try replicate problem 2 using long variable names, job still uses ~200 mb of memory python2, compared ~1.3 gb python3.

during googling came across few other accounts of people encountering memory leaks when using pyroot python3. seems still issue of python 3.6.2 , root 6.08/06, , moment must use python2 if want use pyroot.

so, using python2 appears "solution" now, it's not ideal. if has further information or suggestions i'd grateful hear you!


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -