Last active
August 29, 2015 14:11
-
-
Save wiso/d3c0050b09fa101bead5 to your computer and use it in GitHub Desktop.
THPoly problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compile with: | |
// g++ example_THPoly_Attilafix.cxx -O0 -g `root-config --cflags` `root-config --libs` | |
// first download the file: | |
// wget http://atlas.web.cern.ch/Atlas/GROUPS/DATABASE/GroupData/egammaMVACalib/v1/MVACalib_electron.weights.root | |
// run with valgrind | |
// valgrind --tool=memcheck --suppressions=`root-config --etcdir`/valgrind-root.supp ./a.out | |
#include <cassert> | |
#include <TFile.h> | |
#include <TH2Poly.h> | |
#include <TROOT.h> | |
int main() | |
{ | |
TH2Poly* m_hPoly = 0; | |
TFile* f = TFile::Open("MVACalib_electron.weights.root "); | |
TH2Poly* hPoly = dynamic_cast<TH2Poly*> (f->Get("hPoly")); | |
gROOT->cd(); | |
if (!m_hPoly) m_hPoly = (TH2Poly*) hPoly->Clone(); | |
assert(m_hPoly); | |
f->Close(); | |
delete f; | |
delete m_hPoly; | |
} | |
// valdrind output | |
/* | |
==7022== Memcheck, a memory error detector | |
==7022== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. | |
==7022== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info | |
==7022== Command: ./a.out | |
==7022== | |
==7022== Invalid read of size 4 | |
==7022== at 0x3C23804F9C: TList::Clear(char const*) (in /usr/lib64/root/libCore.so.5.34) | |
==7022== by 0x3C23806022: TList::~TList() (in /usr/lib64/root/libCore.so.5.34) | |
==7022== by 0x3C27BDED6C: TH2Poly::~TH2Poly() (in /usr/lib64/root/libHist.so.5.34) | |
==7022== by 0x3C27BDEE08: TH2Poly::~TH2Poly() (in /usr/lib64/root/libHist.so.5.34) | |
==7022== by 0x3C238062FC: TList::Delete(char const*) (in /usr/lib64/root/libCore.so.5.34) | |
==7022== by 0x3C25ACE8E1: TDirectoryFile::Close(char const*) (in /usr/lib64/root/libRIO.so.5.34) | |
==7022== by 0x3C25AC62A9: TFile::Close(char const*) (in /usr/lib64/root/libRIO.so.5.34) | |
==7022== by 0x400BD0: main (example_THPoly_Attilafix.cxx:28) | |
==7022== Address 0x6fca64c is 12 bytes inside a block of size 80 free'd | |
==7022== at 0x4A078DE: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) | |
==7022== by 0x3C238062FC: TList::Delete(char const*) (in /usr/lib64/root/libCore.so.5.34) | |
==7022== by 0x3C23806022: TList::~TList() (in /usr/lib64/root/libCore.so.5.34) | |
==7022== by 0x3C23806088: TList::~TList() (in /usr/lib64/root/libCore.so.5.34) | |
==7022== by 0x3C27BDED38: TH2Poly::~TH2Poly() (in /usr/lib64/root/libHist.so.5.34) | |
==7022== by 0x3C27BDEE08: TH2Poly::~TH2Poly() (in /usr/lib64/root/libHist.so.5.34) | |
==7022== by 0x3C238062FC: TList::Delete(char const*) (in /usr/lib64/root/libCore.so.5.34) | |
==7022== by 0x3C25ACE8E1: TDirectoryFile::Close(char const*) (in /usr/lib64/root/libRIO.so.5.34) | |
==7022== by 0x3C25AC62A9: TFile::Close(char const*) (in /usr/lib64/root/libRIO.so.5.34) | |
==7022== by 0x400BD0: main (example_THPoly_Attilafix.cxx:28) | |
==7022== | |
==7022== | |
==7022== HEAP SUMMARY: | |
==7022== in use at exit: 7,174,462 bytes in 81,929 blocks | |
==7022== total heap usage: 282,945 allocs, 201,016 frees, 18,551,846 bytes allocated | |
==7022== | |
==7022== LEAK SUMMARY: | |
==7022== definitely lost: 1,128 bytes in 1 blocks | |
==7022== indirectly lost: 130,378 bytes in 1,733 blocks | |
==7022== possibly lost: 0 bytes in 0 blocks | |
==7022== still reachable: 5,049,960 bytes in 60,443 blocks | |
==7022== suppressed: 1,992,996 bytes in 19,752 blocks | |
==7022== Rerun with --leak-check=full to see details of leaked memory | |
==7022== | |
==7022== For counts of detected and suppressed errors, rerun with: -v | |
==7022== ERROR SUMMARY: 1116 errors from 1 contexts (suppressed: 1691 from 86) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment