From 94cf458df1549a7ab9964c01ba9e4911e66b0b5b Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Sat, 16 Sep 2023 20:39:05 -0500 Subject: [PATCH] fix: resolve CKFTracking memory leak (#979) ### Briefly, what does this PR introduce? When there are no track tips, we should delete the ActsExamples::Trajectories before moving on to the next one. Fixes: ``` Direct leak of 128928 byte(s) in 1343 object(s) allocated from: #0 0x556fe8256ded in operator new(unsigned long) (/home/wdconinc/git/EICrecon/.worktree/main/bin/eicrecon+0xeaded) (BuildId: 7089f1e0b4fe65f89c79d38a99df5a0d1554ba34) #1 0x7f0f0594cb83 in eicrecon::CKFTracking::process(boost::container::flat_multiset, ActsExamples::detail::CompareGeometryId, void> const&, std::vector, Acts::Measurement, Acts::Measurement, Acts::Measurement, Acts::Measurement, Acts::Measurement >, std::allocator, Acts::Measurement, Acts::Measurement, Acts::Measurement, Acts::Measurement, Acts::Measurement > > > const&, edm4eic::TrackParametersCollection const&) /home/wdconinc/git/EICrecon/.worktree/main/src/algorithms/tracking/CKFTracking.cc:170:41 #2 0x7f0f0514f9c3 in eicrecon::CKFTracking_factory::Process(std::shared_ptr const&) /home/wdconinc/git/EICrecon/.worktree/main/src/global/tracking/CKFTracking_factory.cc:74:84 #3 0x7f0f0524d104 in JMultifactoryHelperPodio::Process(std::shared_ptr const&) /opt/software/linux-debian12-x86_64_v2/gcc-12.2.0/jana2-2.1.1-txdpt66ozlvvdquuovpy44emsmsnuip4/include/JANA/JMultifactory.h:228:20 #4 0x7f0f0cec0cf7 in JFactory::Create(std::shared_ptr const&) (/usr/._local/jhttvx4bcm3wdo7jmamfg6pazkythsai/lib/libJANA.so+0x59cf7) (BuildId: e11aaf0447ef572861e6577e3cfce0750b7aa2c3) ``` ### What kind of change does this PR introduce? - [x] Bug fix (issue: memory leak) - [ ] New feature (issue #__) - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? No. ### Does this PR change default behavior? No. Co-authored-by: Dmitry Kalinkin --- src/algorithms/tracking/CKFTracking.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/tracking/CKFTracking.cc b/src/algorithms/tracking/CKFTracking.cc index 655ba91e45..4039f405da 100644 --- a/src/algorithms/tracking/CKFTracking.cc +++ b/src/algorithms/tracking/CKFTracking.cc @@ -179,6 +179,7 @@ namespace eicrecon { const auto& trackTips = multiTrajectory->tips(); if (trackTips.empty()) { m_log->debug("Empty multiTrajectory."); + delete multiTrajectory; continue; }