Skip to content

Commit 9f31cd6

Browse files
fix: Properly clean up TList in FairGeoSet
FairGeoSet has non-owning references inside a TList to FairGeoNodes. When the dtor of FairGeoSet is called, those FairGeoNodes might already have been destroyed. Calling `Clear` with `"nodelete"` will just remove all the references without touching them.
1 parent 2668ed5 commit 9f31cd6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

fairroot/geobase/FairGeoInterface.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ FairGeoInterface::~FairGeoInterface()
7979
masterNodes = 0;
8080
}
8181
if (sets) {
82-
/// \bug Leaks "FairGeoSet"s and related resources, prevents memory issues (pr>
83-
/// See: https://github.com/FairRootGroup/FairRoot/issues/1514
84-
// sets->Delete();
82+
sets->Delete();
8583
delete sets;
8684
sets = 0;
8785
}

fairroot/geobase/FairGeoSet.cxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -55,6 +55,12 @@ FairGeoSet::FairGeoSet()
5555
FairGeoSet::~FairGeoSet()
5656
{
5757
// Destructor
58+
if (volumes && !volumes->IsOwner()) {
59+
// destructing a TList that doesn't own its contents
60+
// still touches the objects inside, even if they're
61+
// already destroeyed
62+
volumes->Clear("nodelete");
63+
}
5864
delete volumes;
5965
volumes = 0;
6066
delete modules;

0 commit comments

Comments
 (0)