Hi,
I have been trying to create a dynamic extension to Octave which uses ROOT to read a TTree that represents a series of coincidence events detected in a PET scanner. I will then use Octave’s convenient language to interface with my own C++ reconstruction routines.
While everything was really simple to code, I was getting a strange memory leak. None of my extensions that did not make use of ROOT prsented the problem. Eventually, I found it could be reproduced even with the simplest Octave extension compiled against ROOT one could imagine:
//File memtest.cc
#include <octave/oct.h>
#include <root/TFile.h>
DEFUN_DLD( memtest, args, , “Tests for memory leak.” )
{
return( octave_value() );
}
The code above, compiled with
mkoctfile $(root-config --libs --noauxlibs | sed s/-pthread// | sed s/-rdynamic//) -o memtest.oct memtest.cc
generates a loadable function file memtest.oct, which can be called from Octave if in the path. Repeated calls to this function cause memory usage to grow steadly, but with no apparent regularity in growth size. Both ROOT and Octave are the default ones provided by Ubuntu.
What should I do to better diagnose and solve the problem? Any help will be appreciated.
Thanks in advance,
Elias.