From 6012dc4d594fe320ee3de762f68b12118774440c Mon Sep 17 00:00:00 2001
From: Michel Rasquin <michel.rasquin@cenaero.be>
Date: Thu, 21 Jan 2016 14:49:24 +0000
Subject: [PATCH] Additional memory deallocation

---
 Common/Gmsh.cpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp
index c4c7324780..8b21e4b16f 100644
--- a/Common/Gmsh.cpp
+++ b/Common/Gmsh.cpp
@@ -24,6 +24,7 @@
 #if defined(HAVE_POST)
 #include "PView.h"
 #include "PViewData.h"
+#include "PViewOptions.h"
 #endif
 
 #if defined(HAVE_ONELAB) && !defined(HAVE_ONELAB2)
@@ -231,18 +232,25 @@ int GmshWriteFile(const std::string &fileName)
 int GmshFinalize()
 {
 #if defined(HAVE_POST)
-  // Delete all PViewData stored in static PView list
+  // Delete all PViewData stored in static list of PView class
   for(unsigned int i = 0; i < PView::list.size(); i++) {
     delete PView::list[i];
   }
   PView::list.clear();
-  // Delete static interpolationSchemes
-  PViewData::removeAllInterpolationSchemes();  
+  
+  // Delete static _interpolationSchemes of PViewData class
+  PViewData::removeAllInterpolationSchemes();
+
+  // Delete static _reference of PViewOptions class
+  delete PViewOptions::reference();
 #endif
   // Delete all Gmodels
   for(unsigned int i = 0; i < GModel::list.size(); i++)
     delete GModel::list[i];
   GModel::list.clear();
+  
+  // Delete CTX instance
+  delete CTX::instance();
   return 1;
 }
 
-- 
GitLab