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?
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;
}
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?
[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;’