From 4a55965b70727539a72f27b87668e19f340cb5d4 Mon Sep 17 00:00:00 2001 From: bangerth Date: Sat, 23 Feb 2008 19:57:34 +0000 Subject: [PATCH] Apply a patch by Daniel Goldberg, sent 2008/2/20: Fix a memory leak that made PETSc become gradually slower in time dependent problems where we create and destroy lots of matrices. git-svn-id: https://svn.dealii.org/trunk@15762 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 7 +++++++ deal.II/lac/source/petsc_matrix_base.cc | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index c2ea7c8cfe..422218b44c 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -215,6 +215,13 @@ an integer id of the current thread.
    +
  1. Fixed: The PETScWrappers::MatrixBase::clear_row and +PETScWrappers::MatrixBase::clear_rows functions had a memory leak that made +PETSc become progressively slower over time. This is now fixed. +
    +(Daniel Goldberg 2008/2/20) +
  2. +
  3. Improved: All GrowingVectorMemory objects that have the same template argument will access the same memory pool. Therefore, it is now not a crime any more to just create a memory pool and discard later. Furthermore, diff --git a/deal.II/lac/source/petsc_matrix_base.cc b/deal.II/lac/source/petsc_matrix_base.cc index ff4b69f03b..48cca472d8 100644 --- a/deal.II/lac/source/petsc_matrix_base.cc +++ b/deal.II/lac/source/petsc_matrix_base.cc @@ -214,7 +214,6 @@ namespace PETScWrappers // now set all the entries of this row to // zero - IS index_set; #if (PETSC_VERSION_MAJOR <= 2) && \ ((PETSC_VERSION_MINOR < 2) || \ ((PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0))) @@ -222,6 +221,8 @@ namespace PETScWrappers #else const PetscInt petsc_row = row; #endif + + IS index_set; ISCreateGeneral (get_mpi_communicator(), 1, &petsc_row, &index_set); #if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR <= 2) @@ -234,6 +235,8 @@ namespace PETScWrappers AssertThrow (ierr == 0, ExcPETScError(ierr)); + ISDestroy (index_set); + compress (); } @@ -247,7 +250,6 @@ namespace PETScWrappers // now set all the entries of these rows // to zero - IS index_set; #if (PETSC_VERSION_MAJOR <= 2) && \ ((PETSC_VERSION_MINOR < 2) || \ ((PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0))) @@ -259,6 +261,7 @@ namespace PETScWrappers // call the functions. note that we have // to call them even if #rows is empty, // since this is a collective operation + IS index_set; ISCreateGeneral (get_mpi_communicator(), rows.size(), &petsc_rows[0], &index_set); @@ -272,6 +275,8 @@ namespace PETScWrappers AssertThrow (ierr == 0, ExcPETScError(ierr)); + ISDestroy (index_set); + compress (); } -- 2.39.5