Malloc error with TFile

I am trying to read a file, fill an ntuple with the data inside, and write that data to file. The problem is that there is a lot of data in the file (around 20 million lines, each line has 10 entries or so). When I run my macro, I get the following malloc error:

root.exe(25875) malloc: *** vm_allocate(size=1082036224) failed (error code=3)
root.exe(25875) malloc: *** error: can’t allocate region
root.exe(25875) malloc: *** set a breakpoint in szone_error to debug

I suppose this is telling me that I don’t have enough RAM??? Is there a clever way to get around this (other than buying more RAM)? Is there a way to make root empty its buffer to file (if that is the problem) before the end of the run? Or, if I am completely off base here (probably), can someone explain to me what this error means and how one might get around it?

The essentials of my code are:

TNtuple *ntuple=TNtuple("n","n","x1:x2: ... :angry:10");
TFile *oFile=new TFile("output_file.root","recreate");
ifstream iFile("input_file.txt");
while(iFile>>x1>>x2>> ... >>x10){
    ntuple->Fill(x1,x2, ... ,x10);
}
iFile.close();
ntuple->Write();
oFile->Close();

Thanks so much,

Aaron

Simply invert two lines. Change

TNtuple *ntuple=TNtuple("n","n","x1:x2: ... :x10"); TFile *oFile=new TFile("output_file.root","recreate");
to

TFile *oFile=new TFile("output_file.root","recreate"); TNtuple *ntuple=TNtuple("n","n","x1:x2: ... :x10");
See Users Guide

Rene

You can used a memory based ntuple (which requires the ntuple to fit in memory). Use a disk based ntuple by simply doing (note the alternating of 2 lines):TFile *oFile=new TFile("output_file.root","recreate"); TNtuple *ntuple=TNtuple("n","n","x1:x2: ... :x10"); ifstream iFile("input_file.txt"); while(iFile>>x1>>x2>> ... >>x10){ ntuple->Fill(x1,x2, ... ,x10); } iFile.close(); ntuple->Write(); oFile->Close();

Philippe

Thanks so very much!!!

Aaron