Re: [ROOT] memory leak and differences between root 2.26 and 3.01

From: Timothy E. Miller (tim@bnl.gov)
Date: Wed Nov 28 2001 - 14:33:12 MET


On Tue, 2001-11-27 at 20:49, Stephane Tourneur wrote:
> void draw ()
> {
>   TFile *file = new TFile("Histo2D.root");
>   TString auxhistname = "Trk vs El (d0) ALL CUTS";
>   
>   TH2F* plot = (TH2F*)file->Get(auxhistname);  
>   TH1F* hphi = new TH1F("","",4,0,4);
>   TH1D* hd = new TH1D();   
> 
>     hd = plot->ProjectionX("",50,50); 

At this point, you have replaced the TH1D object you created
with another one generated by the ProjectionX() function call.
When you delete hd later in the code, you delete the ProjectionX()
object and not the one created by the 'new TH1D()' call.
 
Thus, the previous line 'TH1D* hd = new TH1D()' is not necessary.

Also, replace 
     hd = plot->ProjectionX("",50,50); 
with
     TH1D* hd = plot->ProjectionX("",50,50); 

As for the difference in size of the leak, I do not know.
Cheers,
-Tim



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:10 MET