# TTree memory corruption

**URL:** <https://root-forum.cern.ch/t/ttree-memory-corruption/64420>\
**Category:** Newbie\
**Created:** [November 19, 2025, 10:15am UTC](https://root-forum.cern.ch/t/ttree-memory-corruption/64420 "2025-11-19T10:15:52Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![phylmath](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/phylmath/32/38400_2.png) [@phylmath](https://root-forum.cern.ch/u/phylmath)\
**Post date:** [November 19, 2025, 1:29pm UTC](https://root-forum.cern.ch/t/ttree-memory-corruption/64420/3 "2025-11-19T13:29:35Z")

</div>

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

> [@TBasket Problem in root](https://root-forum.cern.ch/t/tbasket-problem-in-root/28313/4):
>
> While the code is running, It is giving this error. It still could be a corrupted file. To exclude this possibility, just write a small example that ‘just’ loop over the entries and call GetEntry, if that works then the file is fine. What is going wrong in this process. I was suspecting, there is some memory issue. You could run your failing example under valgrind with the option --suppressions=$ROOTSYS/etc/valgrind-root.supp and it might give you more information if the problem is ‘memo…

> [@TBasket errors when looping over TTree](https://root-forum.cern.ch/t/tbasket-errors-when-looping-over-ttree/24395):
>
> Hi, I have a tree with 3.7M events, with most branches being vectors of floats or ints. I get thousands of this kind of error at various times with various scripts about 2.2M into the event: Error in \<TBasket::ReadBasketBuffers\>: fNbytes = 189808, fKeylen = 82, fObjlen = 209182, noutot = 0, nout=0, nin=189726, nbuf=209182 Error in \<TBranchElement::GetBasket\>: File: /afs/cern.ch/work/c/cschnaib/public/P5Neutron/ana\_p5.root at byte:16857682192, branch:rh\_pos\_x, entry:2438758, badread=1, nerrors…

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.

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

```

---

_[View the full topic](https://root-forum.cern.ch/t/ttree-memory-corruption/64420)._
