memory leaking in TCanvas ?

From: Piotr Golonka (piters@jakarta.cern.ch)
Date: Sun Jan 24 1999 - 12:28:16 MET


Hello ROOTers!

I'm  developing a programme for my Magister Thesis using ROOT, and found,
that I've got some serious problems with memory leaks. Firstly I examined
my code to find out the source of a problem... and I found out, that the
problem is in TCanvas::Update() method!
I wanted to be sure so I've written a test application:
==========================
#include "TROOT.h"
#include "TRint.h"
#include "TH1.h"
#include "TCanvas.h"
extern void InitGui();
int Error;
VoidFuncPtr_t dictfuncs[] = { InitGui , 0 };

TROOT root("ROOT","ROOT framework object",dictfuncs);

int main(int argc, char** argv)
{

    TRint *theApp = new TRint("CmdLine Interpretter ", &argc, argv, 0, 0);
    TCanvas *c=new TCanvas("c","Phodem+",900,700);
    TH1D *hE  = new TH1D("hE","Electron Energy",200,0.0,2.0);

    for (int i=1;i<=1000;i++) {
      
      printf("EVENT %i \n",i);
      

 	hE->Fill(1);
 	hE->Draw();
	c->Update();
	
  }
   
    theApp->Run();
}
==============================
I've linked it and started UNIX "top" tool to observe its behaviour.
As a histogram was growing up, and Update() method was called (to redraw
the canvas), memory consumed by this program was growing (SIZE and RSS
fields in "top" display). What's the most important: If You remove 
a line with Update() call - memory leaking problem seem to disappear.

I wanted to have my histogram updated after every event generation (that
means thousands of times) - as You expect it starts to consume too much
memory and finally I run out of virtual memory and my program crashes.

Ah, I've almost forgotten: I'm using RedHat LINUX 5.2 on PC/Pentium MMX
200, 32M RAM, ROOT ver. 2.20/06 (17 December 1998)

Please, send Your answers and comments to Piotr.Golonka@cern.ch

cheers!
Piotr



=========================================================================
        "We're all born from the Ashes of Stars..."
                             [ from CERN Summer Students' lectures 1997]
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"In the world with no walls and fences, who needs windows and gates ..."
                                                      [? - a LINUX user]
=========================================================================
Piotr Golonka
CERN Technical Student 1998/99
e-mail: Piotr.Golonka@cern.ch
-------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:28 MET