From 63afe3044b3118301b29e1c153ba0d0671ef37a9 Mon Sep 17 00:00:00 2001 From: kmo Date: Thu, 6 Oct 2011 10:13:58 +0000 Subject: [PATCH] Fixed memory leakage due to missing deletion of the dynamically allocated MPC objects git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@1249 e10b68d5-8a6e-419e-a041-bce267b0401d --- src/ASM/ASMbase.C | 11 +++++++++++ src/ASM/ASMbase.h | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ASM/ASMbase.C b/src/ASM/ASMbase.C index 047a8b25..bfaf28f4 100644 --- a/src/ASM/ASMbase.C +++ b/src/ASM/ASMbase.C @@ -29,6 +29,13 @@ ASMbase::ASMbase (unsigned char n_p, unsigned char n_s, unsigned char n_f) } +ASMbase::~ASMbase () +{ + for (MPCIter it = mpcs.begin(); it != mpcs.end(); it++) + delete *it; +} + + void ASMbase::clear (bool retainGeometry) { if (retainGeometry) // Clear all FE structures, including the elements @@ -37,8 +44,12 @@ void ASMbase::clear (bool retainGeometry) for (size_t i = 0; i < MNPC.size(); i++) MNPC[i].clear(); // Erase the nodes, boundary conditions and multi-point constraints + for (MPCIter it = mpcs.begin(); it != mpcs.end(); it++) + delete *it; + MLGN.clear(); BCode.clear(); + dCode.clear(); mpcs.clear(); } diff --git a/src/ASM/ASMbase.h b/src/ASM/ASMbase.h index f51a96ae..ee6f69f0 100644 --- a/src/ASM/ASMbase.h +++ b/src/ASM/ASMbase.h @@ -75,8 +75,8 @@ protected: ASMbase(unsigned char n_p, unsigned char n_s, unsigned char n_f); public: - //! \brief Empty destructor. - virtual ~ASMbase() {} + //! \brief The destructor frees the dynamically allocated data objects. + virtual ~ASMbase(); //! \brief Checks if this patch is empty. virtual bool empty() const = 0;