Memory exhaust while writing and reading a simple tree

Hi,
I need to store a large tree, (bigger than 1.9GB), during the course of filling tree, I need to read back some previous entries, so the memory exhast while reading the entries.
My root version 4.00.06, memory of my computer is 1GB, and the code is as follows:

TFile aFile = new TFile(“aFile.root”, “RECREATE”);
TTRee::SetMaxTreeSize(1000
Long64_t(2000000000));
TTree *aTree = new TTree(“aTree”, “aTree”);
Double_t weight;
aTree->Branch(“weight”, &weight, “weight/D”);

for(Long64_t i = 0; i < Long64_t(500000000); i++) {
weight = gRandom->Rndm(1);
aTree->Fill();
}
aTree->Write();

for(Long64_t i = 0; i < aTree->GetEntries(); i++) {
aTree->GetEntry(i);
}
aFile->Close();

Memory exhausts while call aTree->GetEntry(i);
which seems to read all entries into the memory, what’s wrong?

Thanks!
Charles

And I find out that memory begins to increase when entry is bigger than
2.7e8

I will look into your problem once I am back to CERN this week.

Rene

This problem is now fixed in the development version in CVS.
The problem happened when writing files bigger than 2 Gbytes and reading it immediatly without closing the file.
A workaround for you is to close the file after writing, open it again and import the tree header.

Rene

Thank you for your help!
I am Looking forward to the next release.