]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Prevent a memory leak in the block matrix base class.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 5 Nov 2008 23:20:44 +0000 (23:20 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 5 Nov 2008 23:20:44 +0000 (23:20 +0000)
git-svn-id: https://svn.dealii.org/trunk@17481 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/lac/include/lac/block_matrix_base.h
deal.II/lac/source/trilinos_block_sparse_matrix.cc

index 30edd5512cad4ad31f5659f8fd3639a7b6ed8b20..5586bff1fe2da06b642c9a6a738449afb8e39a9f 100644 (file)
@@ -322,6 +322,15 @@ inconvenience this causes.
 <h3>lac</h3>
 
 <ol>
+  <li>
+  <p>
+  Fixed: The BlockMatrixBase::clear() function that is used by all other
+  block matrix type classes had a memory leak in that the memory
+  allocated by all sub-objects was not freed. This is now fixed.
+  <br>
+  (WB 2008/11/05)
+  </p>
+
   <li>
   <p>
   New: The function SparsityTools::reorder_Cuthill_McKee reorders
@@ -330,7 +339,6 @@ inconvenience this causes.
   (WB 2008/10/31)
   </p>
 
-
   <li>
   <p>
   New: The function GridTools::get_face_connectivity_of_cells produces a
index 11f81f5494101e67646a2991e7d184fab3a8532d..fe842cbff735c233adf2170d5f335066976bb986 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors
+//    Copyright (C) 2004, 2005, 2006, 2007, 2008 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -1470,7 +1470,11 @@ BlockMatrixBase<MatrixType>::clear ()
 {
   for (unsigned int r=0; r<n_block_rows(); ++r)
     for (unsigned int c=0; c<n_block_cols(); ++c)
-      block(r,c).clear ();
+      {
+       MatrixType *p = this->sub_objects[r][c];
+       this->sub_objects[r][c] = 0;
+       delete p;
+      }
   sub_objects.reinit (0,0);
 
                                    // reset block indices to empty
index 2faa07ecd780bfcec68da979925eddcc217117d7..4fbee6fd4f5d3df4e718df63206ffed54aff0802 100644 (file)
@@ -93,6 +93,9 @@ namespace TrilinosWrappers
       for (unsigned int c=0; c<this->n_block_cols(); ++c)
         {
           BlockType *p = new BlockType();
+
+         Assert (this->sub_objects[r][c] == 0,
+                 ExcInternalError());
           this->sub_objects[r][c] = p;
         }
   }

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.