Potential Memory Leak

I am using the following Macro to create a histogram “Gamma”, whenever I reload the macro in root I get the following message:

Warning in TH1::Build: Replacing existing histogram: Gamma (Potential memory leak).

I thought adding the Gamma->Reset() should take care of that but it didn’t.
the macro is :
{

TCanvas *2d_v1_Gamma = new TCanvas(“2d_v1_Gamma”,"(nOut/nTop) Vs (nb2/cxPE) for Gamma");

Gamma->Reset(); // This will reset the Gamma histogram so you wont
//keep getting the message "Potential Memory Leak"
TH2F *Gamma = new TH2F(“Gamma”,“Gamma”,40,0,17.5,40,0,0.54);

gStyle->SetOptStat(“kFALSE”);
t1->Draw("(nOut/nTop):(nb2/cxPE)>>Gamma",“sqrt(xcorexcore+ycoreycore)*(primary==1 && nTop>55 && nFit>80)”,“COLZ”);
Gamma->GetXaxis()->SetTitle("(nb2/cxPE)");
Gamma->GetYaxis()->SetTitle("(nOut/nTop)");
Gamma->Draw(“COLZ”);

TPaveText *pt = new TPaveText(0.7,0.9,0.9,0.995,“blNDC”);
pt->SetName(“Kharra”);
pt->SetBorderSize(2);
pt->SetFillColor(19);
TText *text = pt->AddText(“Multiplicity Trigger of 50 PMTs”);
pt->Draw();
}
Any ideas :unamused:

Reset() will reset the content, not supress the histogram. To avoid this message (which doesn’t really arm) you can delete the histogram at the end of the macro, or at the beginning if it exist …

Thank you, that worked