3D Histo and memory consumption

Dear all,

  I am reading trying to create 3D plots from vectors obtained by reading a TTree. 

If I create only 2D plots (i.e. comment the lines dealing with 3D plots), the program correctly finishes. If i instead create also one 3D plots (or even only a 3D plot, i.e. comment all the lines dealing with 2D plots), the computer gets frozen, the
mouse stops moving and I have to reboot the computer.
“top” anyhow gets frozen still at a %CPU and %MEMORY around 6%.
Am I trying to allocate too much memory or is there something wrong in my code, pls?
Any help is welcome.

Thanks,
regards,
Franciuska
Plot.C (13.8 KB)
Results.root (525 KB)

With a more recent ROOT version (6.06) it freezes on %CPU = 30 and %MEMORY =54 and after sometimes it crashes giving

terminate called after throwing an instance of 'std::bad_alloc’
what(): std::bad_alloc

Am I doing somethingwrong please?
Is there any way not to run out of memory and filling anyhow all the histograms i want to fill, pls?

Thanks,
regards,
franciuska

Are you aware that each of your 3D histograms uses something like 210MB RAM and you create something like 83 such histograms which results in about 17GB RAM usage?

Hi.

I switched to THnSparse, but THnSparse can not plot.
Therefore I make 3D projections, but this means writing again TH3D* … and ending up with the same problem as before. I realize I am using a lot of memory and cpu.
Should I process histograms one by one, freeing memory each time and adding the new 3D histo on a root file?Or is there any other way, pls?

Thx,
franciuska

As long as you are running on a 64-bit machine with at least 18GB free RAM, your macro should run fine (the resulting “3DPlots.root” file, from the “Results.root” input file, will need only something like 160MB disk space, thanks to the default compression -> your histograms contain mainly zeros).

BTW. As the total number of entries in these 3D histograms seems to be very small, try with some TGraph2D instead.

Hi Franciuska,

And yes, projecting, saving (of drawing + gPad->SaveAs()) and then deleting the histogram makes sense, too!

Cheers, Axel.