Re: [ROOT] memory leak in canvas creation / deletion ?

From: Valeriy Onuchin (Valeri.Onoutchine@cern.ch)
Date: Fri Aug 20 2004 - 10:22:08 MEST


Hi eric, 
first of all - thanks. 



> Hello rooters,
> 
> I have in fact two questions one leading to the second one :
> 
> Question 1 :
> 
> Using ROOT 4.00/08 with GDK on WIN2000
> 
>   *   Version   4.00/08       9 July 2004   *
> Compiled for win32.
> CINT/ROOT C/C++ Interpreter version 5.15.138, May 23 2004
> 
> I suspect a weird memory leak when drawing canvas : I have an 
> application that display a few canvas (in fact 3) in which I draw and 
> updates graphs and histograms over hours, meanwhile the memory usage of 
> the application grows slowly but constantly ( from about 20 M to 100's 
> of Meg, eventually crashing the system). I am quite confident with the 
> rest of the code, because if I remove the drawing of the canvas (keeping 
> creation/deletion of histograms and graphs), the leak doesn't appear, 
> and because of the funniest part : If I iconify the 3 canvases 
> (graphically using the mouse) the memory usage of the application 
> suddently drops to very low (and to what I would expect the application 
> memory usage to be; a few megs ), and then starts again to grow .... 
> until I de-iconify and re-iconify again the canvases...
> It looks to me more like a GDK / microsoft-windows low level interaction 
> than a root problem, did somebody have seen something equivalent ?
> 

It would be good to have a code to reproduce it. 
We fixed few low level memory leaks duiring last year.
Nevertheless, seems something is not yet fixed. Could you check in
"Windows Task Manager" if a number of "GDI Objects" is growing?
.. or you can use "GdiUsage" which is available for free
http://msdn.microsoft.com/msdnmag/issues/03/01/GDILeaks/default.aspx
 

> Question 2 :
> 
> I therefore tried a few things at home on Linux box; namely :
> 
> macro1 :
> {
> TCanvas* c;
> int i;
> for (i=0; i< 10000; i++) {
>    c = new TCanvas();
>    delete c;
> }
> }

.. of cause, we did this good exercise many times ...
seems it's time to repeat it ;-)


Thanks. Regards. Valeriy

> 
> macro2 :
> {
> TH2D* h;
> int j;
> for (j=0; j<10000; j++ ) {
>    h = new TH2D("h","h",1000,0,1,1000,0,1);
>    delete h;
> }
> }
> 
> macro1 shows a memory usage of root.exe that grows constantly,
> macro2 shows a (though oscillating ..) steady memory usage.
> 
> Is this the expected behaviour ?
> 
> 
> eric
> 
> 
> 
> 
> 
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET