Re: [ROOT] Re-question about potential memory leak.

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Aug 12 2002 - 17:13:35 MEST


Hi,

In the current CVS version, this message is not printed anymore.
You can bypass the warning by adding one line in your code.
See below

Rene Brun


On Mon, 12 Aug 2002, Choi Ki-young wrote:

> I had asked this question some weeks later, but I don't receive reply 
> not yet. Sorry about same question re-posting. 
> 
> If I run this program, I met this warning, 
> ------------------------------------------------------------------
> Warning in <TH1::Build>: Replacing existing histogram: TMatrix
> (Potential memory leak).
> ------------------------------------------------------------------
> 
> How can I avoid this warning?
> 
> ----<Source>-----------
> #include <iostream>
> #include <string>
> #include <fstream>
> #include <cmath>
> using namespace std;
> 
> #include "TMatrix.h"
> #include "TCanvas.h"
> 
> int main(void)
> {
> 	TCanvas *c = new TCanvas("c1");
> 	int i,j;
> 
> 	TMatrix Ex(10,10);
> 
> 	for(i=0;i<10;i++)
> 		for(j=0;j<10;j++)
> 			Ex(i,j) = 0.0;
> 	for(i=0;i<10;i++)
> 		for(j=0;j<10;j++)
> 		{
> 			Ex(i,j) = i*j; 
                        delete gDirectory->FindObject("TMatrix");//<==NEW
>                       Ex.Draw("SURF"); 
> 			c->Update();
> 		}
> 
> 
> 	getchar();
> 
> 	return(0);
> }// end of main
> 
> -- 
> Sincerely, Ki-young
> 
> 



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