Std::bad_alloc

Dear all,
I have saved some data-sets in a tree. For each entry, there is an array of X and Y variables, which I am trying to fill in 12 TGraphs by using some conditions. These 12 graphs are latter fit by linear function. The fit parameters of all the 12 graphs are saved in the branch of another TTree. My code snippet works fine for 10^3 entries, but then I am getting a message that the program has been terminated due to “what(): std::bad_alloc”. Can anybody help me how to fix this problem. The small piece of my code snippet is attached with this email.

Thanks in advance.

with regards,
V. Prasad
progm.C (4.47 KB)

Dear all,
I have fixed this problem myself. I just deleted the pointer of TFile before returning the function. Now my code snippet works fine for all the entries.

with regards,
V. Prasad

f1 in ComputeResiduals is leaked.

Apart from that you should at least specify where the exception was thrown since there is no way to run you class implementation with plain ROOT since you included neither the header nor some sort of main function or macro.

Hello Honk,
Thank you very much for your suggestion. Yes, f1 in ComputeResiduals was leaked. I have fixed the same.
Now the code works fine. I will take care your other suggestions in future.

with regards,
V. Prasad