Re: Solved (was Re: [ROOT] memory leak in X)

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Mar 16 2001 - 22:58:31 MET


Hi Damir,
Very good news! This is an excellent indication.
However your proposed solution as a workaround cannot be implemented
because it blocks the command line interface until an event occurs
in the canvas. But it should be very easy to  call  NextEvent
via a new function in the TVirtualX interface. 
Fons will implement the necessary change as soon he is back
from one week holidays somewhere close to the North pole.

Rene Brun

On Fri, 16 Mar 2001, Damir Buskulic wrote:

> Hi Rene,
> 
> After struggling a few hours to make a small X-only (outside root)
> example that shows the leak with XCopyArea behaviour, I noticed that the
> leak happens when one does a series of XCopyArea, without calling
> XNextEvent. If one does an XCopyArea followed by an XNextEvent, the
> problem disappears.
> 
> So there is a workaround. In TCanvas.cxx, the routine TCanvas::Flush()
> (which calls most of the XCopyArea) becomes :
> 
> void TCanvas::Flush()
> {
> //*-*-*-*-*-*-*-*-*Flush canvas
> buffers*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
> //*-*              ====================
>    if (fCanvasID == -1) return;
> 
>    TPad *padsav = (TPad*)gPad;
>    cd();
>    if (!IsBatch()) {
>       gVirtualX->SelectWindow(fCanvasID);
>       gPad = padsav; //don't do cd() because then also the pixmap is
> changed
>       CopyPixmaps();
>       gVirtualX->UpdateWindow(1);
>       int x,y;
>       gVirtualX->RequestLocator(1,1,x,y);
>    }
>    padsav->cd();
> }
> 
> where were only added two lines.
> RequestLocator will just make a call to XNextEvent after each update of
> the canvas. I don't know if my choice of the cursor is the best.
> 
> This seems to work, i.e. there is no memory leak anymore on my machine.
> I didn't test other machines and I don't know what is the effect, say,
> on Windows.
> 
> But I must let you some work, Rene ;-)
> 
> Cheers
> 
> Damir
> 
> Rene Brun wrote:
> > 
> > Hi Damir,
> > 
> > I repeat what we already reported on this topic.
> > The memory leak is on the X server side, not on the application process.
> > This had been traced to XCopyArea. When using bitmaps intensively, the
> > effect becomes important after many screen updates.
> > You can verify this by running the server on a different machine and monitoring
> > the memory growth on the client and server side.
> > 
> > Rene Brun
> > 
> > Damir Buskulic wrote:
> > >
> > > Hi all,
> > >
> > > Some time ago, there was a thread about a memory leak in XFree86
> > > (XCopyArea). As A. Zvyagin pointed out, running
> > >
> > > > root [0] TCanvas *c = new TCanvas("c","c",100,100);
> > > > root [1] while(1) c->Update();
> > >
> > > consumes memory.
> > >
> > > I have the same behaviour on Alpha/OSF1. Did somebody already noticed it
> > > ?
> > >
> > > This may become a big problem, since an online program displaying
> > > varying plots cannot be run more than a few hours without restarting (in
> > > my case, the average leak is a 5-10 MB per hour).
> > > How do people overcome this problem ?
> > >
> > > Cheers
> > >
> > > Damir
> > >
> > > --
> > > =====================================================================
> > > | Damir Buskulic                  | Universite de Savoie/LAPP       |
> > > |                                 | Chemin de Bellevue, B.P. 110    |
> > > | Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux Cedex   |
> > > | e-mail: buskulic@lapp.in2p3.fr  | FRANCE                          |
> > > =====================================================================
> > > mailto:buskulic@lapp.in2p3.fr
> 
> -- 
> =====================================================================
> | Damir Buskulic                  | Universite de Savoie/LAPP       |
> |                                 | Chemin de Bellevue, B.P. 110    |
> | Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux Cedex   |
> | e-mail: buskulic@lapp.in2p3.fr  | FRANCE                          |
> =====================================================================
> mailto:buskulic@lapp.in2p3.fr
> 



This archive was generated by hypermail 2b29 : Fri Jun 08 2001 - 11:51:21 MEST