diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 9d1c352382442725d2b57174f57c659365d2c91e..e5b8e5f2fdc7f0efe39ce915ca0f3c03e3c40506 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) 2015-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 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 6d2120ff0a09ec4859c302cb43c329be3d7c8a19..5ebcdb8d9d62b74e11eb764c4166863e59496b66 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; }