Re: [ROOT] Warning in <TH1::Build>: Replacing existing histogram: h (Potentialmemory leak).

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Oct 29 2003 - 16:08:36 MET


Give a different name to each histogram, ie, instead of:

hprof[j] = new TH1F("h","",Bins[j],Xmin[j],Xmax[j]);
do
hprof[j] = new TH1F(Form("h%d",j),"",Bins[j],Xmin[j],Xmax[j]);

Rene Brun

Venkatesh Kaushik wrote:
> 
> HI ROOTERS,
> I have a question regarding histograms.
> I am getting the above warning every time i compile..
> How do I get rid of it ?
> 
> Thanks for the help.
> Venkat.
> 
>    Here's what I do.
> 
>   /*******************************************/
>    const int num_hist = 7;
>    ...
>    ..
>    TH1F *hprof[num_hist];
> 
>    Int_t Bins[] = { 35, 25, 104, 104, 104, 72, 120};
>    Double_t Xmin[] = {-0.5, -0.5, -0.1, -0.1, -0.1, -0.1, -0.1 };
>    Double_t Xmax[] = {34.5, 24.5, 0.51, 0.51, 0.51, 0.71, 1.1  };
> 
>    for(Int_t j = 0; j < num_hist; j++) {
>          hprof[j] = new TH1F("h","",Bins[j],Xmin[j],Xmax[j]);
>           ... more code here ..
>    }
> 
>   /*************************************/



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