← Back to team overview

dolfin team mailing list archive

Memory leak in EpetraFactory

 

Hello!

Using Valgrind I spotted a memory leak in EpetraFactory. There was a 
Epetra_comm that was not destroyed. The attached patch should fix it.

Johan
# HG changeset patch
# User "Johan Hake <hake@xxxxxxxxx>"
# Date 1222550896 -7200
# Node ID ab198cf7754b38c71909523ed9746280342e9710
# Parent  b0d6ea5999e96592ae63d8b54c2af9d351c0cda9
Fixed a memory leak in EpetraFactory

diff -r b0d6ea5999e9 -r ab198cf7754b dolfin/la/EpetraFactory.cpp
--- a/dolfin/la/EpetraFactory.cpp	Sat Sep 27 20:59:57 2008 +0100
+++ b/dolfin/la/EpetraFactory.cpp	Sat Sep 27 23:28:16 2008 +0200
@@ -17,6 +17,10 @@
 //-----------------------------------------------------------------------------
 EpetraFactory:: EpetraFactory() {
   comm = new Epetra_SerialComm(); 
+}
+//-----------------------------------------------------------------------------
+EpetraFactory:: ~EpetraFactory() {
+  delete comm;
 }
 //-----------------------------------------------------------------------------
 EpetraMatrix* EpetraFactory::create_matrix() const 
diff -r b0d6ea5999e9 -r ab198cf7754b dolfin/la/EpetraFactory.h
--- a/dolfin/la/EpetraFactory.h	Sat Sep 27 20:59:57 2008 +0100
+++ b/dolfin/la/EpetraFactory.h	Sat Sep 27 23:28:16 2008 +0200
@@ -24,7 +24,7 @@
   public:
 
     /// Destructor
-    virtual ~EpetraFactory() {}
+    virtual ~EpetraFactory();
 
     /// Create empty matrix
     EpetraMatrix* create_matrix() const;