From 7dcabcffefe9cc904163480acbe016af2d71f21d Mon Sep 17 00:00:00 2001 From: Anton Riedel Date: Sun, 27 Oct 2024 16:18:09 +0100 Subject: [PATCH] Fix: fix memory leak in ClusterVisualizer Special care has to be taken when handling ClustersData objects. They contain a o2::mergers::MergeInterface object which needs to be deleted explicitly. Wrapping the ClustersData object which is pulled from CCDB ensures the memory is appropiately freed at the end of update method. --- Modules/TPC/src/ClusterVisualizer.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/TPC/src/ClusterVisualizer.cxx b/Modules/TPC/src/ClusterVisualizer.cxx index 89a06455ea..8a8fe23680 100644 --- a/Modules/TPC/src/ClusterVisualizer.cxx +++ b/Modules/TPC/src/ClusterVisualizer.cxx @@ -161,9 +161,9 @@ void ClusterVisualizer::update(Trigger t, framework::ServiceRegistryRef) auto calDetIter = 0; - auto clusterData = mCdbApi.retrieveFromTFileAny(mPath, - mLookupMaps.size() > 1 ? mLookupMaps.at(calDetIter) : mLookupMaps.at(0), - mTimestamps.size() > 0 ? mTimestamps.at(calDetIter) : t.timestamp); + std::unique_ptr clusterData(mCdbApi.retrieveFromTFileAny(mPath, + mLookupMaps.size() > 1 ? mLookupMaps.at(calDetIter) : mLookupMaps.at(0), + mTimestamps.size() > 0 ? mTimestamps.at(calDetIter) : t.timestamp)); auto& clusters = clusterData->getClusters();