RE: [ROOT] histogram draw memory leak

From: Philippe Canal (pcanal@fnal.gov)
Date: Wed Dec 03 2003 - 20:42:34 MET


Hi,

I was able to reproduce a very small leak with 3.05/07.
This leak seems to disappear with 3.10/02.
So I recommend that you upgrade to the latest version of ROOT.

Cheers,
Philippe.

PS. For performance reason, it is preferable to avoid the new/Draw/delete
cycle.
In your example, just doing Reset will do.  Similar optmization are
available
even in complex case.

#include "TCanvas.h"
#include "Rtypes.h"
#include "TH1.h"
#include "TApplication.h"
#include "TSystem.h"
#include "TObjectTable.h"
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
  TApplication theApp("App", &argc,argv);
  const UInt_t nloops = 20000;

  TCanvas* c1 = new TCanvas("c1","c1",800,600);
  TH1F* h1 = new TH1F("h1","h1",10,0,10);
  h1->Draw();
  for(size_t i=0;i<nloops;i++){
    h1->Reset();
    h1->Fill(1,5);
    h1->Fill(2,8);
    c1->Modified();
    c1->Update();
    if(((i+1)%10)==0) {
      cout<<"i= "<<i+1<<endl;
      //gObjectTable->Print();
    }
  }
}

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Jianglai Liu
Sent: Wednesday, December 03, 2003 1:48 AM
To: roottalk@cern.ch
Subject: [ROOT] histogram draw memory leak


Dear ROOTers,

I know this has been a very old topic. But somehow I got stuck on it. I
have a realtime cusumer program, which will display histograms
periodically onto a canvas. I deleted the histograms after each
Draw, but observed a serious increase of the memory usage.

I reproduced the problem with the attached small code. I compiled it into
an executable and ran it, and oberved the increasing memory usage clearly
with "top". I tried to set the histogram kCanDelete bit, and tried
"delete" as well as "Delete()", none of these helped.
gObjectTable->Print() didn't show any extra objects when the program ran
...

On the other hand, if I modify this code into a ROOT CINT script, I
couldn't observe the leak within 2000 draws. So there must be magic
somewhere.

I am using a RH 9 system, and ROOT 3.05/07 compiled with gcc3.2. I would
be really appreciated if someone offers help! Thanks!

Jianglai


#################################################################
#################################################################
#################################################################
#####
#####
#####
#################################################################
#################################################################
#################################################################



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:17 MET