Hello,
I would like to have a questions regard to the suppression valgrind report on the ROOT class.
I create a test code as follow:
#include <cstdio>
#include <cstdlib>
#include <TFile.h>
int* create_ptr( int size )
{
int* ptr = (int*)malloc( size*sizeof(int) );
return ptr;
}
int main( void )
{
TFile* file = TFile::Open( "afile.root", "recreate" );
int* ptr1 = create_ptr( 5 );
int* ptr2 = (int*)malloc( 10*sizeof(int) );
free( ptr1 );
free( ptr2 );
file -> Close( );
delete file;
return 0;
}
I compiled my code with:
g++ -g -o mem-leak mem-leak.C `root-config --libs --cflags`
and run the memory test with:
valgrind --num-calller=30 -suppressions=$ROOTSYS/etc/valgrind-root.supp ./mem-leak
as suggested on several topics, for example this one.
I expected that valgrind should show no memory leak as I deleted/freed all heap memory, but I still got leak reported.
==356921== Memcheck, a memory error detector
==356921== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==356921== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==356921== Command: ./mem-leak
==356921==
==356921==
==356921== HEAP SUMMARY:
==356921== in use at exit: 11,833,202 bytes in 16,312 blocks
==356921== total heap usage: 210,338 allocs, 194,026 frees, 114,836,210 bytes allocated
==356921==
==356921== LEAK SUMMARY:
==356921== definitely lost: 0 bytes in 0 blocks
==356921== indirectly lost: 0 bytes in 0 blocks
==356921== possibly lost: 0 bytes in 0 blocks
==356921== still reachable: 11,788,018 bytes in 15,683 blocks
==356921== suppressed: 45,184 bytes in 629 blocks
==356921== Rerun with --leak-check=full to see details of leaked memory
==356921==
==356921== For lists of detected and suppressed errors, rerun with: -s
==356921== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 102 from 6)
Did I run the valgrind command correctly? If not, how to correct it?
Thank you very much.
ROOT Version: 6.24
Platform: CentOS 7
Compiler: g++ std=c++11