From: kanschat Date: Mon, 17 Dec 2007 19:56:16 +0000 (+0000) Subject: test new GrowingVectorMemory functionality X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73ea691f49661a1742550c8360b98be74cba2260;p=dealii-svn.git test new GrowingVectorMemory functionality git-svn-id: https://svn.dealii.org/trunk@15605 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/lac/Makefile b/tests/lac/Makefile index 7a80bdd012..7ae78a04de 100644 --- a/tests/lac/Makefile +++ b/tests/lac/Makefile @@ -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 index 0000000000..828166a844 --- /dev/null +++ b/tests/lac/vector_memory.cc @@ -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 +#include +#include + +#include + +using namespace dealii; + +template +void +test_leak() +{ + GrowingVectorMemory mem; + VECTOR* v = mem.alloc(); + v->reinit(5); +} + + +template +void +test_stat() +{ + GrowingVectorMemory 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 >(); + + try + { + test_leak >(); + test_leak >(); + } + 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 index 0000000000..2d37ba2dce --- /dev/null +++ b/tests/lac/vector_memory/cmp/generic @@ -0,0 +1,11 @@ + +DEAL::GrowingVectorMemory:Overall allocated vectors: 10 +DEAL::GrowingVectorMemory:Maximum allocated vectors: 6 +An error occurred in file in function + dealii::GrowingVectorMemory::~GrowingVectorMemory() [with VECTOR = dealii::Vector] +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