TChain memory usage with compiled root

Hello !

I am using compiled ROOT and tried the following :

  • To start an interactive session, create a tchain, add some root trees
    I used valgrind to spot memory leaks and here is the result for an interactive session.
    No problem I would say.
> valgrind --tool=memcheck --suppressions=$ROOTSYS/etc/valgrind-root.supp root -l 
$ TChain *ch = new TChain("MyTree");
$ ch->Add("file-*.root");
[...]
==998== HEAP SUMMARY:
==998==     in use at exit: 82 bytes in 1 blocks
==998==   total heap usage: 3 allocs, 2 frees, 270 bytes allocated
==998== 
==998== LEAK SUMMARY:
==998==    definitely lost: 0 bytes in 0 blocks
==998==    indirectly lost: 0 bytes in 0 blocks
==998==      possibly lost: 0 bytes in 0 blocks
==998==    still reachable: 82 bytes in 1 blocks
==998==         suppressed: 0 bytes in 0 blocks
==998== Rerun with --leak-check=full to see details of leaked memory
==998== 
==998== For counts of detected and suppressed errors, rerun with: -v
==998== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 8 from 6)
  • On the other hand, I compiled a root code: “./myprog.C”
    And I do the exact same (see attachment)
> valgrind --tool=memcheck --suppressions=$ROOTSYS/etc/valgrind-root.supp ./myprog
[...]
==21654== HEAP SUMMARY:
==21654==     in use at exit: 8,305,499 bytes in 97,124 blocks
==21654==   total heap usage: 3,656,106 allocs, 3,558,982 frees, 513,917,846 bytes allocated
==21654== 
==21654== LEAK SUMMARY:
==21654==    definitely lost: 102,240 bytes in 4,146 blocks
==21654==    indirectly lost: 414 bytes in 19 blocks
==21654==      possibly lost: 34 bytes in 1 blocks
==21654==    still reachable: 5,951,155 bytes in 70,314 blocks
==21654==         suppressed: 2,251,656 bytes in 22,644 blocks
==21654== Rerun with --leak-check=full to see details of leaked memory
==21654== 
==21654== For counts of detected and suppressed errors, rerun with: -v
==21654== Use --track-origins=yes to see where uninitialised values come from
==21654== ERROR SUMMARY: 21 errors from 1 contexts (suppressed: 6457 from 127)

And here there are a lot of memory leaks . What did I forgot in my compiled code to get such huge memory leak ? (of course it’s increasing when I increase the amount of files !) I would expect ROOT to delete the resident memory.

Thank you and cheers,

myprog.C (391 Bytes)

You never deleted the chain you created:

int main(int argc, char **argv)
{
	TChain *ch = new TChain("MyTree");
	ch->Add("./file-*.root");
	cout << ch->GetEntries() << endl;
        delete ch; //We need to call delete when we use new!
        return 0;
}

Or let C++ do it for you:

int main(int argc, char **argv)
{
	TChain ch("MyTree");
	ch.Add("./file-*.root");
	cout << ch.GetEntries() << endl;
        return 0;
}

Hi ! Sorry I mistaken in the file I uploaded (I am working on lxplus and uploaded from my computer) >.<
I added the “delete ch” of course !!

Still the problem I confirm.
Btw I am using : /afs/cern.ch/sw/lcg/app/releases/ROOT/5.34.36/x86_64-slc6-gcc49-opt/root/bin/root (not the last ROOT 6…)

delete ch;
ch = NULL;

In practice with more details, I get this : valgrind.txt (2.0 KB)

I am loading the files stored on my EOS : “root://eosuser.cern.ch//eos/user/m/meyerma/escalade-production/dy2015t3-p7/dy15W11t3-nh3/hist-262*.root”

No idea ? Maybe I need to use a command to clean all objects in root memory ?

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