I’ve noticed that the memory use of the ROOT process increases gradually when I read from a TTree. I am not certain if I am not dealing with some kind of caching, but I attempted to disable caches and the result did not change.
The first GetEntry() increases the resident memory use by ~53.5 MB, virtual by ~182 MB. Subsequent ~6000 calls to GetEntry(j) gradually increase the resident memory by ~68 MB. The virtual memory first drops slightly, returning to about the same value as after the first GetEntry().
So the memory use of the process increases by ~68 MB while reading ~6600 entries.
If it does not then the memory fluctuation is just due to the slight difference in size of the basket and possibly on some memory ‘hoarding’ (holding on to buffer that are slightly too large) to reduce the amount of memory churn (too many memory allocations and de-allocations which both reduce scaling with number of threads and can increase the amount of virtual memory needed (due to memory fragmentation).
This confirms that there is no leak but rather a ‘slow’ ramped up to the maximum memory usage. To reduce the usage you can reduce the size of the TTreeCache (also making the reading a bit slower) or replace call to TTree::GetEntry to calls to TTree::LoadTree and TBranch::GetEntry for ‘just’ the branch you actually need.
Thanks. I am fine with this use. As the memory use was growing with the numbers of entries read I suspected a memory leak, and was afraid that it will be much more serious with bigger trees, but with your explanation I am calm.