[ROOT] TGraph/TCanvas memory leaks

From: gmoloche@mit.edu
Date: Tue May 21 2002 - 17:18:02 MEST


I am updating a previous post.

I looked into the source code for TCanvas and TGraph and a lot of objects are 
instantiated in the heap there. It seems that the problem is that the ROOT 
people can't figure out how to keep a picture on the screen after a script is 
finished, and at the same time, properly destroying all those objects 
afterwards. Is this an ongoing issue that it's going to be corrected or do I 
have to learn to live with it? It's not a lot of trouble restarting ROOT every 
once in a while anyway. But this seriously handicaps ROOT as a library for 
standalone, compiled, interactive, applications.

My previous post was:

After enabling gObjectTable->Print() and executing the commands below in win2k 
ROOT 3.02 I expected to obtain the same results after the second and fourth 
ObjectTable->Print() (see below) but this is not the case.

Is this a memory leak or am I overlooking something?

The "leak" persists even if I omit the Draw and GetXaxis statements. If I use 
Update() and Modified() more objects are "leaked".

I also tried putting gr1 and c1 in the stack (getting rid of delete statmts), 
and gObjectTable->Print gives the same results.

Repeated calls keep accumulating objects so sooner or later, ROOT crashes.

Thanks in advance for any response.
---------------------------------------------------------------------------
(starting a fresh ROOT session)

gObjectTable->Print(); // first
gObjectTable->Print(); // second
gROOT->Reset();
Double_t t[10];
Double_t p[10];
TCanvas *c1 = new TCanvas("plot","Plotting");
TGraph  *gr1 = new TGraph(10,t,p);
gr1->SetBit(kCanDelete);
gr1->Draw("AL");
gr1->GetXaxis()->SetTimeDisplay(1);
gr1->GetXaxis()->SetTimeFormat("%H:%M");
delete gr1;
delete c1;
gROOT->Reset();
gObjectTable->Print(); // third
gObjectTable->Print(); // fourth



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:53 MET