Hunting Mem Leaks in Root

Hey all,
I have a file that I’d like to compile in root and hunt down memory leaks. I would like to use valgrind to do it, but compiling within root seems to obscure the original file lines to valgrind, and gives me no useful information about what lines errors occur on. I’ve been running “valgrind --tool=memcheck --leak-check=full root.exe .L MY_FILE.C+” and again can’t really get much useful information out of valgrind with this. Has anyone had similar experience tracking memory leaks in their root code that could possibly help me out? As an example, I get output like…

==18751== 5,184 bytes in 72 blocks are possibly lost in loss record 28,495 of 28,619
==18751== at 0x4C28CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==18751== by 0x500B5F9: TStorage::ObjectAlloc(unsigned long) (in /usr/lib/root/5.18/libCore.so.5.18)
==18751== by 0xB5713AE: TGComboBox::Init() (in /usr/lib/root/5.18/libGui.so.5.18)
==18751== by 0xB571BD4: TGComboBox::TGComboBox(TGWindow const*, int, unsigned int, unsigned long) (in /usr/lib/root/5.18/libGui.so.5.18)
==18751== by 0x9D6ACAE: MCProduction::Window() (in /MYWORKINGDIRECTORY/MY_FILE.so)
==18751== by 0x9D6BFE0: G__fileqjsljR_1791_0_30(G__value*, char const*, G__param*, int) (in /MY WORKINGDIRECTORY/MY_FILE.so)
==18751== by 0x5837154: Cint::G__CallFunc::Execute(void*) (in /usr/lib/root/5.18/libCint.so.5.18)
==18751== by 0x4FFA4D7: TQConnection::ExecuteMethod() (in /usr/lib/root/5.18/libCore.so.5.18)
==18751== by 0x4FFE231: TQObject::Emit(char const*) (in /usr/lib/root/5.18/libCore.so.5.18)
==18751== by 0xB548094: TGButton::EmitSignals(bool) (in /usr/lib/root/5.18/libGui.so.5.18)
==18751== by 0xB549EE7: TGButton::HandleButton(Event_t*) (in /usr/lib/root/5.18/libGui.so.5.18)
==18751== by 0xB59D4FE: TGFrame::HandleEvent(Event_t*) (in /usr/lib/root/5.18/libGui.so.5.18)

Any information I have appears to be about the compiled .so file, and I’m not sure how to translate this into useful help tracking bugs in the original .C!
Thanks so much in advance,
Chris

As described in the Users Guide, run with the valgrind suppression file, eg:

valgrind --tool=memcheck \ --suppressions=$ROOTSYS/etc/valgrind-root.supp \ root.exe
Rene

Thanks for the help Rene. I’ve got it running the the custom suppressions now, but unfortunately that hasn’t resolved the original issue. I’m still getting no useful output that relates back to original lines in my .C file. Any idea how I’d go about enabling such things? The output is still the same as above.

Hi,

Well there is at least:[quote]
==18751== by 0xB571BD4: TGComboBox::TGComboBox(TGWindow const*, int, unsigned int, unsigned long) (in /usr/lib/root/5.18/libGui.so.5.18)
==18751== by 0x9D6ACAE: MCProduction::Window() (in /MYWORKINGDIRECTORY/MY_FILE.so)[/quote]so it is related to the gui created by your macro. For example it could be that you re-create the TGComboBox object each time Window is called and/or that you never deleted (and/or that your use is tickling a leak there).

Cheers,
Philippe.

Thanks for the help, Phillipe. I suppose that narrows it down a bunch, but unfortunately I’m creating a fair few TGComboBoxes in Window(). Nonetheless, it’s a good start so thank you much. I suppose I should have been a little more investigative than just looking at the message and demanding to see a line in my file where things are going wrong, so I’ll redouble the effort :slight_smile: