Hello ROOTers,
Consider the following, very simple test program:
[code]#include “TFile.h”
#include “TH1F.h”
int main() {
TFile f(“test.root”,“RECREATE”);
TH1F *h = new TH1F(“h”,“h”,10,0.,1.);
f.Write();
f.Close();
return 0;
}[/code]
I compile this as
Valgrind sees a memory leak, although I use the ROOT suppressions file:
$ valgrind --leak-check=full --suppressions=/etc/root/valgrind-root.supp --num-callers=50 ./testROOT
==6291== Memcheck, a memory error detector
==6291== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==6291== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==6291== Command: ./testROOT
==6291==
==6291==
==6291== HEAP SUMMARY:
==6291== in use at exit: 3,691,202 bytes in 41,980 blocks
==6291== total heap usage: 97,194 allocs, 55,214 frees, 7,567,580 bytes allocated
==6291==
==6291== 32 bytes in 1 blocks are possibly lost in loss record 16,436 of 31,402
==6291== at 0x4C28147: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==6291== by 0x4FF5D5C: TString::Replace(int, int, char const*, int) (in /usr/lib/x86_64-linux-gnu/root5.34/libCore.so.5.34)
==6291== by 0x61E61FC: TStreamerInfo::Compile() (in /usr/lib/x86_64-linux-gnu/root5.34/libRIO.so.5.34)
==6291== by 0x61D6CC6: TStreamerInfo::Build() (in /usr/lib/x86_64-linux-gnu/root5.34/libRIO.so.5.34)
==6291== by 0x5050356: TClass::GetStreamerInfo(int) const (in /usr/lib/x86_64-linux-gnu/root5.34/libCore.so.5.34)
==6291== by 0x61D78AA: TStreamerInfo::Build() (in /usr/lib/x86_64-linux-gnu/root5.34/libRIO.so.5.34)
==6291== by 0x618BD50: TBufferFile::WriteClassBuffer(TClass const*, void*) (in /usr/lib/x86_64-linux-gnu/root5.34/libRIO.so.5.34)
==6291== by 0x61C5D11: TKey::TKey(TObject const*, char const*, int, TDirectory*) (in /usr/lib/x86_64-linux-gnu/root5.34/libRIO.so.5.34)
==6291== by 0x61A04A9: TFile::CreateKey(TDirectory*, TObject const*, char const*, int) (in /usr/lib/x86_64-linux-gnu/root5.34/libRIO.so.5.34)
==6291== by 0x619A9A9: TDirectoryFile::WriteTObject(TObject const*, char const*, char const*, int) (in /usr/lib/x86_64-linux-gnu/root5.34/libRIO.so.5.34)
==6291== by 0x4FD8D35: TObject::Write(char const*, int, int) const (in /usr/lib/x86_64-linux-gnu/root5.34/libCore.so.5.34)
==6291== by 0x6198AF0: TDirectoryFile::Write(char const*, int, int) (in /usr/lib/x86_64-linux-gnu/root5.34/libRIO.so.5.34)
==6291== by 0x61A0F74: TFile::Write(char const*, int, int) (in /usr/lib/x86_64-linux-gnu/root5.34/libRIO.so.5.34)
==6291== by 0x400D6F: main (testROOT.cc:7)
==6291==
==6291== LEAK SUMMARY:
==6291== definitely lost: 0 bytes in 0 blocks
==6291== indirectly lost: 0 bytes in 0 blocks
==6291== possibly lost: 32 bytes in 1 blocks
==6291== still reachable: 2,715,667 bytes in 30,748 blocks
==6291== suppressed: 975,503 bytes in 11,231 blocks
==6291== Reachable blocks (those to which a pointer was found) are not shown.
==6291== To see them, rerun with: --leak-check=full --show-reachable=yes
==6291==
==6291== For counts of detected and suppressed errors, rerun with: -v
==6291== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 73 from 73)
Is this a bug, or am I incorrectly handling my TFile?
I’m using ROOT v5.34.
Thanks in advance,
Davide