Memory leak when reading TTree with ROOT 6 in Python

Dear Colleagues,

there seems to be a memory leak when reading array branches from a TTree in ROOT 6 using PyROOT.

The attached script (maker.py) creates a Tree with one a array and one scalar per entry. The other script (simple.py) then loops over the Tree and reads the array-branch.

Using ROOT 6 (6.05.02 from afs) this causes a steady increase in memory (last column is resource.getrusage(resource.RUSAGE_SELF).ru_maxrss in MB):

Processing 50000 events (out of 50000 events)
0.0% (0 out of 50000) 119.748
10.0% (5001 out of 50000) 122.296
20.0% (10002 out of 50000) 123.696
30.0% (15003 out of 50000) 124.9
40.0% (20004 out of 50000) 126.584
50.0% (25005 out of 50000) 127.62
60.0% (30006 out of 50000) 128.908
70.0% (35007 out of 50000) 130.48
80.0% (40008 out of 50000) 131.744
90.0% (45009 out of 50000) 133.028

While ROOT 5 (5.34.32, again from afs) is nice and steady:

Processing 50000 events (out of 50000 events)
0.0% (0 out of 50000) 45.712
10.0% (5001 out of 50000) 45.868
20.0% (10002 out of 50000) 45.868
30.0% (15003 out of 50000) 45.868
40.0% (20004 out of 50000) 45.868
50.0% (25005 out of 50000) 45.868
60.0% (30006 out of 50000) 45.868
70.0% (35007 out of 50000) 45.868
80.0% (40008 out of 50000) 45.868
90.0% (45009 out of 50000) 45.868

Commenting out the branch access input_tree.myval makes ROOT 6 well behaved as well (with a memory usage of around 122 MB). This means the increase due to the leak is much larger than the input file which is around 600kB.

Using scalar or std::vector branches did not show this problem.

Any help would be much appreciated.

Thank you &
Cheers,
Gregor

maker.py (472 Bytes)
simple.py (817 Bytes)

Replace all the tree business with just this call in the loop:ROOT.TClassEdit.ResolveTypedef( "Float_t*", True )Still leaks. I’d say is bug.

-Dom

Thanks - good point. I posted it also as:
https://sft.its.cern.ch/jira/browse/ROOT-7657

Cheers,
Gregor

Hi Dom,

Both the original python issue and the TClassEdit::ResolveTypedef’s memory hoarding has been resolved (for the common cases, hard cases involving templates might still cost).

Cheers,
Philippe.