]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add destructor to PETScWrappers::MPI::SparseMatrix to not leak memory
authorTimo Heister <timo.heister@gmail.com>
Mon, 5 Aug 2013 22:41:29 +0000 (22:41 +0000)
committerTimo Heister <timo.heister@gmail.com>
Mon, 5 Aug 2013 22:41:29 +0000 (22:41 +0000)
git-svn-id: https://svn.dealii.org/trunk@30233 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h
deal.II/source/lac/petsc_parallel_sparse_matrix.cc

index 6bfa4df7dd3e8df3dc77bace4b5c1043d90ef185..115bb94bfce1522b00ca72461db933188eb16e06 100644 (file)
@@ -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
index e366b66458b53cd427ad0b2fa3528a3a5d6973ea..6e91035df75019f0ac27841dedef8dd4243e1129 100644 (file)
@@ -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,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.