Possible memory leak when using ROOT.std.pair in a vector

I’m trying the following simple code. It consume a huge amount of memory (~20 GB). The size of a vector<pair<int,float>> is 24 byte, I thus expect the total memory consumption is 24*4e5 ~10MB. Could it be a memory leak or I didn’t use the pyROOT correctly? Any helps are appreciated.

ROOT version: ROOT 6.12/07
python version: 2.7.14

import ROOT

nmax = 400000
a = ROOT.std.vector('pair<int, float>')(nmax)

for i in range(nmax):
    if i%10000 ==0:
        print(i, '\n')
    a[i] = ROOT.std.pair('int, float')(1, 2)

Hi @wx2017,
ROOT 6.12 is very old in PyROOT years. I just tried with v6.22/06, I get:

$ /usr/bin/time python repro_wx2017.py
...
3.87user 0.42system 0:04.30elapsed 99%CPU (0avgtext+0avgdata 420292maxresident)k
416inputs+40outputs (2major+44145minor)pagefaults 0swaps

Does this look more reasonable? (could you verify that the latest ROOT version does not require 20GB of RAM to execute that script?)

Cheers,
Enrico

That’s indeed the case. The newer version has no issue at all. Thanks for the help!

1 Like

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