Hello all,
I am defining a histogram like
[code]char name2X[15];
sprintf(name2X,“Pos_g2xcl_%i”,iterNb);
TH1F* h_Pos_g2xcl = new TH1F(name2X,"",100,-10,110);[/code]
inside a for loop over iterNb.
I would like to delete each histogram inside the for loop for each value of iterNb, because of memory problem. So, please let me know how can I do this.
Thanks in advance for help.
with regards,
Ram
TH1F* h_Pos_g2xcl = new TH1F(name2X,"",100,-10,110);
// ... do whatever you want with h_Pos_g2xcl ...
delete h_Pos_g2xcl;
Dear Coyote,
Thanks for reply.
I tried this earlier but its not working.
initially it shows me warning
then finally it goes into segfault.
If I don’t use
delete h_Pos_g2xcl;
then it is working fine. But then my PC goes out of memory after some time.
Is there any another way to do this?
with regards,
Ram
TH1F *h_Pos_g2xcl = ((TH1F *)(gROOT->FindObject(name2X)));
delete h_Pos_g2xcl; // delete the old name2X
h_Pos_g2xcl = new TH1F(name2X,"",100,-10,110);