Error: Symbol G__exception in while loop

Dear all,

again I have a memory leak problem. This time because of fitting a graph of which the data are vary. The fitting is stopped when the optimal fitting result is reached. I have the impression that the fit parameters are stored and hence consume more and more memory. Is there any possibility how to avoid this?

Thanks for helping me again.

Cornelia

while((fitparam1<=0)&&(fitparam0!=0)){
TGraph g2 =new TGraph();
backmean-=backmean
0.5;

 for(radius=1;radius<=maxdist;radius+=1.0){
integral=0;

      for(int x=580;x<795;x++){
      for(int y=530;y<720;y++){

	if(radius**2>((x-maxx)**2+(y-maxy)**2)){
	  integral+=datacleaned[x][y]-backmean;
	} 
      }
    }
    g2->SetPoint(z,radius*pixelsize*1000,integral);
    z++;
 }

g2->Fit(“pol1”,"","",fitminpixelsize1000,2pixelpixelsize*1000);

    fitparam0=pol1->GetParameter(0);
    fitparam1=pol1->GetParameter(1);
    g1->SetPoint(q,backmean,fitparam1);
   
    q++;
  }
}

Hi,

Each loop creates a new TGraph object that is never deleted, is that the intent?

Philippe.

Probably you are right. I though that the fit was the problem. And I thought that using the same pointer for the Graph that the formal graph is deleted. Isn’t that true?

[quote] And I thought that using the same pointer for the Graph that the formal graph is deleted. Isn’t that true?[/quote]No since you explicitly (via new TGraph) ask for a new object every single loop. The code would behave how you express it if it looks like:TGraph *g2 =new TGraph(); while((fitparam1<=0)&&(fitparam0!=0)){ ... }However this would mean that all the point of all the iteration would be accumulated in the same TGraph object … which may or may not be what you want.

If you need a new TGraph object for each iteration use something like: while((fitparam1<=0)&&(fitparam0!=0)){ TGraph *g2 =new TGraph(); ... delete g2; }

Cheers,
Philippe.

O.k. I understand.

The second code you stated is what I need.
Last question: What about the fit I am calling each iteration?
This will be deleted from the memory automatically?

Thanks!!!

[quote]Last question: What about the fit I am calling each iteration?
This will be deleted from the memory automatically? [/quote]
Yes, they will be delete as a consequence of the call to ‘delete graph;’

Cheers,
Philippe.