]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
test new GrowingVectorMemory functionality
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 17 Dec 2007 19:56:16 +0000 (19:56 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 17 Dec 2007 19:56:16 +0000 (19:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@15605 0785d39b-7218-0410-832d-ea1e28bc413d

tests/lac/Makefile
tests/lac/vector_memory.cc [new file with mode: 0644]
tests/lac/vector_memory/cmp/generic [new file with mode: 0644]

index 7a80bdd0121d590ef46d7028007b7ac011e35a1c..7ae78a04de27dbee79c795892ac3d437636e4642 100644 (file)
@@ -20,7 +20,7 @@ default: run-tests
 
 ############################################################
 
-tests_x = vector-vector \
+tests_x = vector-vector vector_memory \
        full_matrix \
        householder \
        tridiagonal_matrix \
diff --git a/tests/lac/vector_memory.cc b/tests/lac/vector_memory.cc
new file mode 100644 (file)
index 0000000..828166a
--- /dev/null
@@ -0,0 +1,87 @@
+//--------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2007 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//--------------------------------------------------------------------
+
+
+#include <base/exceptions.h>
+#include <lac/vector_memory.h>
+#include <lac/vector.h>
+
+#include <fstream>
+
+using namespace dealii;
+
+template<class VECTOR>
+void
+test_leak()
+{
+  GrowingVectorMemory<VECTOR> mem;
+  VECTOR* v = mem.alloc();
+  v->reinit(5);
+}
+
+
+template<class VECTOR>
+void
+test_stat()
+{
+  GrowingVectorMemory<VECTOR> mem(1, true);
+  VECTOR* v1 = mem.alloc();
+  VECTOR* v2 = mem.alloc();
+  VECTOR* v3 = mem.alloc();
+  VECTOR* v4 = mem.alloc();
+  VECTOR* v5 = mem.alloc();
+  VECTOR* v6 = mem.alloc();
+  v1->reinit(5);
+  v2->reinit(5);
+  v3->reinit(5);
+  v4->reinit(5);
+  v5->reinit(5);
+  v6->reinit(5);
+  mem.free(v1);
+  mem.free(v2);
+  mem.free(v3);
+  mem.free(v4);
+  mem.free(v5);
+  mem.free(v6);
+  v1 = mem.alloc();
+  mem.free(v1);
+  v1 = mem.alloc();
+  mem.free(v1);
+  v1 = mem.alloc();
+  mem.free(v1);
+  v1 = mem.alloc();
+  mem.free(v1);
+}
+
+
+int
+main()
+{
+  std::ofstream logfile("vector_memory/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test_stat<Vector<double> >();
+  
+  try
+    {
+      test_leak<Vector<double> >();
+      test_leak<Vector<float> >();
+    }
+  catch (StandardExceptions::ExcMemoryLeak e)
+    {
+      e.print_exc_data(logfile);
+      e.print_info(logfile);
+    }
+}
diff --git a/tests/lac/vector_memory/cmp/generic b/tests/lac/vector_memory/cmp/generic
new file mode 100644 (file)
index 0000000..2d37ba2
--- /dev/null
@@ -0,0 +1,11 @@
+
+DEAL::GrowingVectorMemory:Overall allocated vectors: 10
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 6
+An error occurred in file <vector_memory.h> in function
+    dealii::GrowingVectorMemory<VECTOR>::~GrowingVectorMemory() [with VECTOR = dealii::Vector<double>]
+The violated condition was: 
+    current_alloc == 0
+The name and call sequence of the exception was:
+    StandardExceptions::ExcMemoryLeak(current_alloc)
+Additional Information: 
+Destroying memory handler while 1 objects are still allocated

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.