Dear experts,
I am having huge memory leak while using N-dimensional histograms with THnSparse.
My code contains function and its input - two not empty 9-dimensional histograms and this number of bins for each dimension - {8, 12, 8, 8, 9, 9, 9, 9, 5}. I don’t see any memory leak in code, but when I run it 7 GB of my RAM dies before the function is over.
Thanks,
Dmitriy
void FillCDF(THnSparseF* H_sig, THnSparseF* H_bkg){
Float_t B = 0, S = 0;
Int_t* p0 = new Int_t[9];
Int_t* p1 = new Int_t[9];
for(Int_t binI = H_sig->GetAxis(0)->GetNbins(); binI>=1; --binI){
for(Int_t binJ=H_sig->GetAxis(1)->GetNbins(); binJ>=1; --binJ){
for(Int_t binK=H_sig->GetAxis(2)->GetNbins(); binK>=1; --binK){
for(Int_t binL=H_sig->GetAxis(3)->GetNbins(); binL>=1; --binL){
for(Int_t binM=1; binM<=H_sig->GetAxis(4)->GetNbins(); ++binM){
for(Int_t binN=H_sig->GetAxis(5)->GetNbins(); binN>=1; --binN){
for(Int_t binO=1; binO<=H_sig->GetAxis(6)->GetNbins(); ++binO){
for(Int_t binP=H_sig->GetAxis(7)->GetNbins(); binP>=1; --binP){
for(Int_t binR=1; binR<=H_sig->GetAxis(8)->GetNbins(); ++binR){
p0[0] = binI;
p0[1] = binJ;
p0[2] = binK;
p0[3] = binL;
p0[4] = binM;
p0[5] = binN;
p0[6] = binO;
p0[7] = binP;
p0[8] = binR;
B = H_bkg->GetBinContent(p0);
S = H_sig->GetBinContent(p0);
for(Int_t I=0; I<=1; I++){
for(Int_t J=0; J<=1; J++){
for(Int_t K=0; K<=1; K++){
for(Int_t L=0; L<=1; L++){
for(Int_t M=0; M<=1; M++){
for(Int_t N=0; N<=1; N++){
for(Int_t O=0; O<=1; O++){
for(Int_t P=0; P<=1; P++){
for(Int_t R=0; R<=1; R++){
if(I+J+K+L+M+N+O+P+R>0){
p1[0] = binI+I;
p1[1] = binJ+J;
p1[2] = binK+K;
p1[3] = binL+L;
p1[4] = binM-M;
p1[5] = binN+N;
p1[6] = binO-O;
p1[7] = binP+P;
p1[8] = binR-R;
B=B-pow(-1, I+J+K+L+M+N+O+P+R)*H_bkg->GetBinContent(p1);
S=S-pow(-1, I+J+K+L+M+N+O+P+R)*H_sig->GetBinContent(p1);
}}}}}}}}}}
H_sig->SetBinContent(p0, S);
H_bkg->SetBinContent(p0, B);
}}}}}}}}}}
ROOT Version: ROOT 6.18/04