Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/client.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/client.cpp	(revision 2309)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/client.cpp	(revision 2310)
@@ -492,5 +492,5 @@
       CContext::removeAllContexts() ; // free memory for related context 
 
-
+      CXios::getMpiGarbageCollector().release() ; // release unfree MPI ressources
       if (!is_MPI_Initialized)
       {
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/context_client.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/context_client.cpp	(revision 2309)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/context_client.cpp	(revision 2310)
@@ -335,8 +335,14 @@
         MPI_Intercomm_create(commSelf_, 0, interCommMerged_, clientSize+rank, 0, &interComm) ;
         MPI_Intercomm_merge(interComm, false, &winComm_[rank]) ;
+        CXios::getMpiGarbageCollector().registerCommunicator(winComm_[rank]) ;
         MPI_Comm_free(&interComm) ;
         windows_[rank].resize(2) ;
+        
         MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][0]);
+        CXios::getMpiGarbageCollector().registerWindow(windows_[rank][0]) ;
+        
         MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][1]);   
+        CXios::getMpiGarbageCollector().registerWindow(windows_[rank][1]) ;
+
         CTimer::get("create Windows").suspend() ;
       }
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.cpp	(revision 2309)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.cpp	(revision 2310)
@@ -162,7 +162,11 @@
         MPI_Intercomm_create(commSelf_, 0, interCommMerged_, rank, 0 , &interComm) ;
         MPI_Intercomm_merge(interComm, true, &winComm_[rank]) ;
+        CXios::getMpiGarbageCollector().registerCommunicator(winComm_[rank]) ;
+        MPI_Comm_free(&interComm) ;
         windows_[rank].resize(2) ;
         MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][0]);
+        CXios::getMpiGarbageCollector().registerWindow(windows_[rank][0]) ;
         MPI_Win_create_dynamic(MPI_INFO_NULL, winComm_[rank], &windows_[rank][1]);
+        CXios::getMpiGarbageCollector().registerWindow(windows_[rank][1]) ;
         CTimer::get("create Windows").suspend() ;
         MPI_Barrier(winComm_[rank]) ;
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/cxios.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/cxios.cpp	(revision 2309)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/cxios.cpp	(revision 2310)
@@ -59,4 +59,6 @@
   CRegistryManager*   CXios::registryManager_=nullptr ;
 
+  CMpiGarbageCollector CXios::MpiGarbageCollector_  ;
+
   //! Parse configuration file and create some objects from it
   void CXios::initialize()
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/cxios.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/cxios.hpp	(revision 2309)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/cxios.hpp	(revision 2310)
@@ -11,4 +11,5 @@
 #include "coupler_manager.hpp"
 #include "registry_manager.hpp"
+#include "mpi_garbage_collector.hpp"
 
 namespace xios
@@ -75,6 +76,7 @@
      static CContextsManager* contextsManager_ ;
      static CDaemonsManager* daemonsManager_ ;
-     
-
+     static CMpiGarbageCollector MpiGarbageCollector_  ;
+    public:
+     static CMpiGarbageCollector& getMpiGarbageCollector(void) { return MpiGarbageCollector_ ; }
     public:
      //! Setting xios to use server mode
@@ -111,5 +113,5 @@
      static CDaemonsManager*    getDaemonsManager(void) { return daemonsManager_ ;}
      static CPoolRessource*     getPoolRessource(void) ;
-
+     
      static MPI_Comm getGlobalComm(void) { return globalComm ;}
      static MPI_Comm getXiosComm(void) { return xiosComm ;}
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/mpi_garbage_collector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/mpi_garbage_collector.hpp	(revision 2310)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/mpi_garbage_collector.hpp	(revision 2310)
@@ -0,0 +1,34 @@
+#ifndef __MPI_GARBAGE_COLLECTOR_HPP__
+#define __MPI_GARBAGE_COLLECTOR_HPP__
+#include "mpi.hpp"
+namespace xios
+{
+  class CMpiGarbageCollector
+  {
+    
+    private:
+
+      struct SType
+      {
+        enum {COMM, WIN} type ;
+        MPI_Comm comm ;
+        MPI_Win win ;
+        std::string str;
+      } ;
+      std::list<SType> stack_ ;
+    
+    public:
+
+      void registerCommunicator(MPI_Comm& comm, std::string str="") { stack_.push_back(SType{SType::COMM, comm, MPI_WIN_NULL, str}) ;}
+      void registerWindow(MPI_Win& win, std::string str="") { stack_.push_back(SType{SType::WIN, MPI_COMM_NULL, win, str}) ;}
+      void release(void)
+      {
+        for( auto& it : stack_) 
+          if (it.type==SType::COMM) MPI_Comm_free(&it.comm);
+          else if (it.type==SType::WIN) MPI_Win_free(&it.win);
+      }
+  } ;
+
+}
+
+#endif
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/server.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/server.cpp	(revision 2309)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/server.cpp	(revision 2310)
@@ -320,4 +320,6 @@
       CContext::removeAllContexts() ; // free memory for related context
           
+      CXios::getMpiGarbageCollector().release() ; // release unfree MPI ressources
+
       if (!is_MPI_Initialized)
       {
