JeffersonLab / hpstr

Heavy Photon Search Toolkit for Reconstruction
2 stars 18 forks source link

Remove use of `TObject::Clone` in `NewVtxAnaProcessor` #190

Closed tomeichlersmith closed 6 months ago

tomeichlersmith commented 6 months ago

The use of TObject::Clone on the tracks within a vertex is causing a small but measurable memory leak in NewVtxAnaProcessor. Using memory_profiler to measure and plot the memory usage.

On the current master branch, we see a steady increase in the memory usage as events are processed. hpstr-master

While on this branch, the memory usage is stabilized to (roughly) the same value which is the core design principle of ROOT's serialization technique with TTrees. hpstr-rm-clone

We can even process the full 10M event sample without reaching the memory used in the 1M-event-limited run on master. hpstr-rm-clone-full-10M

Context

I am using hps-env:2024.01.23 to build and run hpstr (look there for details of the dependencies). What I do want to emphasize is that I am running with C++17 enabled.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d701c5..d3edaf8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,9 +3,9 @@ cmake_minimum_required(VERSION 3.18)

 project(hpstr)

-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 17)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
-set(CMAKE_C_STANDARD 14)
+set(CMAKE_C_STANDARD 17)
 set(CMAKE_C_STANDARD_REQUIRED ON)

 if(NOT CMAKE_BUILD_TYPE)

which is NOT on this branch and is not tested.