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

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Aug 23 2004 - 10:52:49 MEST


Hi Eric,

Thanks for reporting the memory leak when creating/deleting canvases. We will
fix this problem.

Concerning your macro2, this is the expected behaviour. There is no leak. This
is simply the C++ memory fragmentation problem where the compiler tries to
optimize a large buffer of small objects being created/deleted.

Rene Brun

eric.anciant@noos.fr wrote:
> 
> 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 ?
> 
> 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;
> }
> }
> 
> 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