Terminate called after throwing an instance of 'std::bad_al

Hi Rooter,

I have 285 ntuple files (each file about 2GB), and I have to plot 3d histograms from there. So, I added them in TChain. After few hours of run, it crashes with following error:

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

So, I ran again and monitored the memory uses (the computer is multi-code with 32GB RAM, 32bit Linux). Because 32bit does not allow more than 2GB memory/per process, I guess, it started to use swap after filling up 2GB memory. After filling about 1300MB swap, it crashed (swap is 40GB, a lot of space).

The code is simple:

TH3D *dist = new TH3D("dist", "dist", pBin, pMin, pMax, phiBin, phiMin,phiMax,thetaBin,thetaMin, thetaMax);
TChain *ch = new TChain("tree");
ch->Add("*.root");
ch->Draw("theta:phi:p >> dist", Cuts);

However for other trees which has few millions less event then this, does not crash.

Any suggestions?
Thanks.

[quote]Because 32bit does not allow more than 2GB memory/per process, I guess, it started to use swap after filling up 2GB memory.[/quote]No, it actually throws an std::bad_alloc because there is no way to represent the more than 2GB in a 32bit pointer.

It sounds like Draw is creating a TGraph rather than an histogram. Try the following: TDirectory distdir = gDirectory; TH3D *dist = new TH3D("dist", "dist", pBin, pMin, pMax, phiBin, phiMin,phiMax,thetaBin,thetaMin, thetaMax); TChain *ch = new TChain("tree"); ch->Add("*.root"); distdir->cd(); ch->Draw("theta:phi:p >> dist", Cuts);or

TH3D *dist = new TH3D("dist", "dist", pBin, pMin, pMax, phiBin, phiMin,phiMax,thetaBin,thetaMin, thetaMax); TChain *ch = new TChain("tree"); ch->Add("*.root"); ch->Draw("theta:phi:p >> dist", Cuts, "hist");

Cheers,
Philippe.