Dear all,
I often use CINT in order to run several times routines that I have just compile. I create, for instance, my pointer to canvas
and can not delete it, because otherwise I won’t see it.
Rerunning the same code several times without quitting CINT would then lead to this:
[quote]root [2] .L routines/H_Display.cpp++
root [3] display_beamprofile(20)
root [4] display_beamprofile(20)
Warning in TH1::Build: Replacing existing histogram: Positions (Potential memory leak).[/quote]
and indeed, after a while, the probability for a segfault increases…
I know that this custom code works, to avoid the problem:
TCanvas* canprof = 0;
if(gROOT->FindObject("can_profiles")) {
can = (TCanvas*) gROOT->FindObject("can_profiles");
delete can;
}
canprof = new TCanvas("can_profiles","",50,50,800,800);
However, this looks like a possible overloading of the “new” operator would ease a lot, by doing all this at once:
Is there such an implementation or a variant or anything similar available?
Thanks!