]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
fix some of the PETSc memory leaks
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 Aug 2013 22:07:43 +0000 (22:07 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 Aug 2013 22:07:43 +0000 (22:07 +0000)
git-svn-id: https://svn.dealii.org/trunk@30231 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 0c0cf8ae63d6b4c89351d5b7817e37a6b4a2f86e..bc3ee07627c093a25ead661bcce5079a2f395327 100644 (file)
@@ -594,9 +594,17 @@ namespace PETScWrappers
           // Vector x,v;x=v;
           // we skip the code below and create a simple serial vector of
           // length 0
+
+          int ierr;
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+          ierr = VecDestroy (vector);
+#else
+          ierr = VecDestroy (&vector);
+#endif
+          AssertThrow (ierr == 0, ExcPETScError(ierr));
+
           const int n = 0;
-          const int ierr
-                  = VecCreateSeq (PETSC_COMM_SELF, n, &vector);
+          ierr = VecCreateSeq (PETSC_COMM_SELF, n, &vector);
           AssertThrow (ierr == 0, ExcPETScError(ierr));
           ghosted = false;
           ghost_indices.clear();
index 9aeafe4839f1094fe4da5c59bac33730df3d78f0..848ba3eec1eb0dfd0a7c9db2b2f677783abf6e01 100644 (file)
@@ -194,6 +194,14 @@ namespace PETScWrappers
                     const IndexSet &ghost,
                     const MPI_Comm     &comm)
     {
+      int ierr;
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+      ierr = VecDestroy (vector);
+#else
+      ierr = VecDestroy (&vector);
+#endif
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+
       communicator = comm;
 
       Assert(local.is_contiguous(), ExcNotImplemented());
@@ -215,6 +223,14 @@ namespace PETScWrappers
     Vector::reinit (const IndexSet &local,
                     const MPI_Comm &comm)
     {
+      int ierr;
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+      ierr = VecDestroy (vector);
+#else
+      ierr = VecDestroy (&vector);
+#endif
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+
       communicator = comm;
 
       Assert(local.is_contiguous(), ExcNotImplemented());

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.