From fddc578d38832b8c64a1e1f97fc092cff9e24f3b Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Tue, 7 Mar 2017 18:56:59 +0100 Subject: [PATCH] Introduce function to delete all unused vectors in GrowingVectorMemory --- include/deal.II/lac/vector_memory.h | 10 +++++++++ source/lac/CMakeLists.txt | 1 + source/lac/vector_memory.cc | 11 ++++++++++ source/lac/vector_memory_release.inst.in | 27 ++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 source/lac/vector_memory_release.inst.in diff --git a/include/deal.II/lac/vector_memory.h b/include/deal.II/lac/vector_memory.h index 72fd8edf16..2f75561709 100644 --- a/include/deal.II/lac/vector_memory.h +++ b/include/deal.II/lac/vector_memory.h @@ -348,6 +348,16 @@ private: static Threads::Mutex mutex; }; + + +namespace internal +{ + namespace GrowingVectorMemory + { + void release_all_unused_memory(); + } +} + /*@}*/ #ifndef DOXYGEN diff --git a/source/lac/CMakeLists.txt b/source/lac/CMakeLists.txt index 6f9a93f9d1..5d6de52c71 100644 --- a/source/lac/CMakeLists.txt +++ b/source/lac/CMakeLists.txt @@ -74,6 +74,7 @@ SET(_inst sparse_matrix.inst.in vector.inst.in vector_memory.inst.in + vector_memory_release.inst.in vector_view.inst.in ) diff --git a/source/lac/vector_memory.cc b/source/lac/vector_memory.cc index 76aeb5980f..ef86a5e231 100644 --- a/source/lac/vector_memory.cc +++ b/source/lac/vector_memory.cc @@ -32,4 +32,15 @@ DEAL_II_NAMESPACE_OPEN #include "vector_memory.inst" +namespace internal +{ + namespace GrowingVectorMemory + { + void release_all_unused_memory() + { +#include "vector_memory_release.inst" + } + } +} + DEAL_II_NAMESPACE_CLOSE diff --git a/source/lac/vector_memory_release.inst.in b/source/lac/vector_memory_release.inst.in new file mode 100644 index 0000000000..17564ede57 --- /dev/null +++ b/source/lac/vector_memory_release.inst.in @@ -0,0 +1,27 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 1999 - 2016 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +for (VECTOR : SERIAL_VECTORS) +{ + dealii::GrowingVectorMemory::release_unused_memory(); +} + +for (SCALAR : COMPLEX_SCALARS) +{ + dealii::GrowingVectorMemory >::release_unused_memory(); + dealii::GrowingVectorMemory >::release_unused_memory(); +} -- 2.39.5