From: heister Date: Mon, 5 Aug 2013 22:41:29 +0000 (+0000) Subject: add destructor to PETScWrappers::MPI::SparseMatrix to not leak memory X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bae228912561ffa7929a4d12fa247d294603499;p=dealii-svn.git add destructor to PETScWrappers::MPI::SparseMatrix to not leak memory git-svn-id: https://svn.dealii.org/trunk@30233 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h b/deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h index 6bfa4df7dd..115bb94bfc 100644 --- a/deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h @@ -158,6 +158,11 @@ namespace PETScWrappers */ SparseMatrix (); + /** + * Destructor to free the PETSc object. + */ + ~SparseMatrix (); + /** * Create a sparse matrix of * dimensions @p m times @p n, with diff --git a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc index e366b66458..6e91035df7 100644 --- a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc +++ b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc @@ -43,6 +43,14 @@ namespace PETScWrappers } + SparseMatrix::~SparseMatrix () + { +#if DEAL_II_PETSC_VERSION_LT(3,2,0) + const int ierr = MatDestroy (matrix); +#else + const int ierr = MatDestroy (&matrix); +#endif + } SparseMatrix::SparseMatrix (const MPI_Comm &communicator, const size_type m,