TTree memory corruption


ROOT Version: 6.32.04
Platform: WSL2 Ubuntu

Hello! I am getting an error when storing large ROOT files. For context, I am generating 5 million events in PYTHIA, storing results into multiple TTrees, and then reading these in another script to study. When running the second script, I get repeated errors in my terminal as shown below.

To make it readable, I have copy-pasted the repeating error message below:

R__unzip: error -5 in inflate (zlib)
Error in <TBasket::ReadBasketBuffers>: fNbytes = 4836146, fKeylen = 77, fObjlen = 5301454, noutot = 0, nout=0, nin=4836069, nbuf=5301454
Error in <TBranchElement::GetBasket>: File: 4-GenData/gen_FCC365.root at byte:6790900984, branch:parEto, entry:3701793, badread=1, nerrors=9, basketnumber=397
R__unzip: error -5 in inflate (zlib)
Error in <TBasket::ReadBasketBuffers>: fNbytes = 4836146, fKeylen = 77, fObjlen = 5301454, noutot = 0, nout=0, nin=4836069, nbuf=5301454
file probably overwritten: stopping reporting error messages
===>File is more than 2 Gigabytes
R__unzip: error -5 in inflate (zlib)
Error in <TBasket::ReadBasketBuffers>: fNbytes = 4836146, fKeylen = 77, fObjlen = 5301454, noutot = 0, nout=0, nin=4836069, nbuf=5301454

I am guessing this has something to do with exceeding the memory of the TTree itself? Since I do not face this issue with 1M samples (the file size is now 8.9GB). Looking forward to your inputs. Thanks in advance :slight_smile:

Did you try to search the forum? Search results for 'R__unzip: error -5 in inflate order:latest' - ROOT Forum
If you did and didn’t find any suitable answer, then maybe we can ask @pcanal to take a look

Hello. Yes, I had searched the forum but the two closest cases don’t have a resolution.

Hence hoping I can get input here. In any case, I have kept the simulations to run again with the following additions to increase TTree size and widen basket size. I will check if it works now.

tree->SetMaxTreeSize(200LL * 1024 * 1024 * 1024);
const int BASKET = 128000;
tree->GetBranch("branch_1")->SetBasketSize(BASKET);
.
.
tree->GetBranch("branch_23")->SetBasketSize(BASKET);