Finding Memory Leaks in Root programs

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Feb 17 2000 - 16:04:23 MET


In the past few days, I had to process several problems related to
memory
leaks in user applications. It was easy to find the origin of all these
leaks
by using a Root utility.
  When you suspect a leak (say in an event loop for example), just add
the following statement:
  gObtectTable->Print();
at regular intervals in your loop(s)
(In a compiled program, add #include TObjectTable.h")
This will show a table with the number of objects per class.
To take advantage of this facility, you must also activate it in your
.rootrc file.
    Root.ObjectStat:         1

Obviously TObjectTable::Print will not be able to find all the leaks
in your program, but I have seen that most leaks coming from C++
beginners
can be traced this way.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:19 MET