diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 254d9a6735ff3cef85db6f72a634b2a1bbb36b6b..25ee99ba46ed18414213a9b590fe1bd30f69edce 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011, 2015-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011, 2015-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2017 OpenFOAM Foundation @@ -727,6 +727,9 @@ Foam::Time::~Time() // Clean up profiling profiling::stop(*this); + + // Ensure all owned objects are also cleaned up now + objectRegistry::clear(); } diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.C b/src/OpenFOAM/db/objectRegistry/objectRegistry.C index 3e1fbebc055855e5fbdbddc68ca1fd4929354dff..0c9535f35a03a97cf87ab00f1ac364c27f821eaa 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.C @@ -323,6 +323,14 @@ void Foam::objectRegistry::clear() if (ptr && ptr->ownedByRegistry()) { + // TBD: may wish to have ptr->clearWatches(); + + if (objectRegistry::debug) + { + Pout<< "objectRegistry::clear : " << ptr->name() + << " watches :" << flatOutput(ptr->watchIndices()) << nl; + + } delete ptr; } } @@ -350,6 +358,7 @@ bool Foam::objectRegistry::erase(const iterator& iter) if (ptr && ptr->ownedByRegistry()) { + // TBD: may wish to have ptr->clearWatches(); delete ptr; }