Re: memory leaking in TCanvas ?

From: Piotr Golonka (piters@jakarta.cern.ch)
Date: Mon Jan 25 1999 - 08:05:31 MET


On Sun, 24 Jan 1999, Valeriy Onuchin wrote:

> Hi Piotr!
> When you hE->Draw(); 
> that  add pointer to  hE to ListOfPrimitieves
> of TPad where you draw ,in your case this is 
> TCanvas c.
> 
>  You should do it only ones ,  all 
> drawing will be done by c->Modified();  c->Update();
> see code below:
> 
> hE->Draw();
> 
>     for (int i=1;i<=1000;i++) {
>       
>       printf("EVENT %i \n",i);
>       
> 
>         hE->Fill(1);
>         c->Modified();
>         c->Update();
>         
>    }
>    
> this one of the reason , alhough there are could be others.
>  
>                   With best regards.            Valery
> 

Thank You!
Of course this colud be the reason, but not the most important one.
The leakage is approximately 160kB/1000 redraws that makes about
0.16kB/redraw = 160 bytes. That is much more than a size of single
pointer! What's more - when I was looking for a reason, I was using a
"hit-or-miss" method: I was commenting out line-after-line to find the one
that causes the leak. It was c->Update(), not hE->Draw(), to be the most
serious one.
BTW, Isn't there a protection in Draw() method for adding an object
another time to a ListOfPrimitives ? 

thanks once again!
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