Describe the bug
I am trying to build a Go4 analysis which gets TTrees sent from an unpacker through a TSocket and then fills some histograms based on these trees. This means I will read a lot of TTrees. I find that whenever I map them, the memory usage of my program increases slightly. This will eventually become a problem.
I have created a small program which reproduces the problem. If I comment out the lines which map the branches, memory usage is constant.
I don’t see any suspicious in the output from Valgrind (attached).
valgrindOutput.zip (609.3 KB)
Am I missing something? Why does memory usage increase when doing this?
To Reproduce
I have this code which produces the problem:
int main() {
auto _adcU1FE = std::shared_ptr<UInt_t>(new UInt_t[16], std::default_delete<UInt_t[]>());
auto _adcU1BE = std::shared_ptr<UInt_t>(new UInt_t[16], std::default_delete<UInt_t[]>());
auto _adcU2FE = std::shared_ptr<UInt_t>(new UInt_t[16], std::default_delete<UInt_t[]>());
auto _adcU2BE = std::shared_ptr<UInt_t>(new UInt_t[16], std::default_delete<UInt_t[]>());
auto file = new TFile("/home/jeppe/Downloads/run_050.root","READ"); //would get TMemFile here instead
auto tree = (TTree*)file->Get("h101");
for(int i = 0; i < 1e8; i++){
tree->SetBranchStatus("*", false);
tree->SetBranchAddress("U1F_E",_adcU1FE.get());
tree->SetBranchAddress("U1B_E",_adcU1BE.get());
tree->SetBranchAddress("U2F_E",_adcU2FE.get());
tree->SetBranchAddress("U2B_E",_adcU2BE.get());
tree->ResetBranchAddresses();
tree->SetBranchStatus("*", false);
}
return 0;
}
The specific file I use can be downloaded from here: https://anon.erda.au.dk/share_redirect/GTN2E1yfHG (40 MB download starts immediately upon click)
Setup
ROOT v6.34.08
Built for linuxx8664gcc on Apr 07 2025, 20:24:19
From tags/v6-34-08@v6-34-08
With c++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Binary directory: /home/jeppe/devel/res/root/bin
Installed with binary download.