Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/client.cpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/client.cpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/client.cpp	(revision 2265)
@@ -487,5 +487,5 @@
       CTimer::get("XIOS init/finalize",false).suspend() ;
       CTimer::get("XIOS").suspend() ;
-      
+      CContext::removeAllContexts() ; // free memory for related context 
       CXios::finalizeDaemonsManager() ;
 
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/interface/c/icdata.cpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/interface/c/icdata.cpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/interface/c/icdata.cpp	(revision 2265)
@@ -135,4 +135,5 @@
      CContext* context = CContext::getCurrent();
      context->finalize();
+     CContext::removeContext(context->getId()) ;
      CTimer::get("XIOS context finalize").suspend();
      CTimer::get("XIOS").suspend();
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/manager/server_context.cpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/manager/server_context.cpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/manager/server_context.cpp	(revision 2265)
@@ -252,4 +252,6 @@
       if (context_->eventLoop())
       {
+        info(100)<<"Remove context server with id "<<context_->getId()<<endl ;
+        CContext::removeContext(context_->getId()) ;
         context_=nullptr ;
         // destroy context ??? --> later
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/calendar_wrapper.hpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/calendar_wrapper.hpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/calendar_wrapper.hpp	(revision 2265)
@@ -82,4 +82,5 @@
   }; // class CCalendarWrapper
 
+  typedef CCalendarWrapper CCalendarWrapperGroup;
   typedef CCalendarWrapper CCalendarWrapperDefinition;
 } // namespace xios
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp	(revision 2265)
@@ -289,4 +289,42 @@
    CATCH
 
+void CContext::removeContext(const string& contextId)
+{
+  #define DECLARE_NODE(Name_, name_)     CObjectFactory::deleteContext< C##Name_ >(contextId);
+  #define DECLARE_NODE_PAR(Name_, name_) CObjectFactory::deleteContext< C##Name_ >(contextId);
+  #include "node_type.conf"
+  #define DECLARE_NODE(Name_, name_)     CObjectFactory::deleteContext< C##Name_##Group >(contextId);
+  #define DECLARE_NODE_PAR(Name_, name_) 
+  #include "node_type.conf"
+
+/*
+  #define DECLARE_NODE(Name_, name_)     CObjectFactory::dumpObjects< C##Name_##Group >();
+  #define DECLARE_NODE_PAR(Name_, name_) 
+  #include "node_type.conf"
+
+  #define DECLARE_NODE(Name_, name_)     CObjectFactory::dumpObjects< C##Name_>();
+  #define DECLARE_NODE_PAR(Name_, name_) 
+  #include "node_type.conf"
+*/
+}
+
+void CContext::removeAllContexts(void)
+{
+  #define DECLARE_NODE(Name_, name_)     CObjectFactory::deleteAllContexts< C##Name_ >();
+  #define DECLARE_NODE_PAR(Name_, name_) CObjectFactory::deleteAllContexts< C##Name_ >();
+  #include "node_type.conf"
+  #define DECLARE_NODE(Name_, name_)     CObjectFactory::deleteAllContexts< C##Name_##Group >();
+  #define DECLARE_NODE_PAR(Name_, name_) 
+  #include "node_type.conf"
+/*
+  #define DECLARE_NODE(Name_, name_)     CObjectFactory::dumpObjects< C##Name_##Group >();
+  #define DECLARE_NODE_PAR(Name_, name_) 
+  #include "node_type.conf"
+
+  #define DECLARE_NODE(Name_, name_)     CObjectFactory::dumpObjects< C##Name_>();
+  #define DECLARE_NODE_PAR(Name_, name_) 
+  #include "node_type.conf"
+*/
+}
    ///---------------------------------------------------------------
 
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp	(revision 2265)
@@ -246,4 +246,6 @@
         static void ShowTree(StdOStream & out = std::clog);
         static void CleanTree(void);
+        static void removeContext(const std::string& contextId);
+        static void removeAllContexts(void) ;
         int getServiceType(void) {return serviceType_;}
 
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_factory.hpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_factory.hpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_factory.hpp	(revision 2265)
@@ -54,8 +54,10 @@
              static std::shared_ptr<U> CreateAlias(const StdString& id, const StdString& alias) ;
          
-         template <typename U> static const StdString& GetUIdBase(void);
+         template <typename U> static const StdString GetUIdBase(void);
          template <typename U> static StdString GenUId(void);
          template <typename U> static bool IsGenUId(const StdString& id);
-
+         template <typename U> static void deleteContext(const StdString & context) ;
+         template <typename U> static void deleteAllContexts(void) ;
+         template <typename U> static void dumpObjects(void) ;
       private :
 
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_factory_decl_macro.hpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_factory_decl_macro.hpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_factory_decl_macro.hpp	(revision 2265)
@@ -14,8 +14,12 @@
   template std::shared_ptr<U> CObjectFactory::CreateObject<U>(const StdString& id ); \
   template std::shared_ptr<U> CObjectFactory::CreateAlias<U>(const StdString& id, const StdString& alias ); \
-  template const StdString& CObjectFactory::GetUIdBase<U>(void); \
+  template const StdString CObjectFactory::GetUIdBase<U>(void); \
   template StdString CObjectFactory::GenUId<U>(void); \
-  template bool CObjectFactory::IsGenUId<U>(const StdString& id);
+  template bool CObjectFactory::IsGenUId<U>(const StdString& id);\
+  template void CObjectFactory::deleteContext<U>(const StdString & context) ;\
+  template void CObjectFactory::deleteAllContexts<U>() ;\
+  template void CObjectFactory::dumpObjects<U>(void) ;
 
 
 
+
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_factory_impl.hpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_factory_impl.hpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_factory_impl.hpp	(revision 2265)
@@ -147,7 +147,7 @@
 
    template <typename U>
-   const StdString& CObjectFactory::GetUIdBase(void)
-   {
-      static StdString base ; 
+   const StdString CObjectFactory::GetUIdBase(void)
+   {
+      StdString base ; 
 //      base = "__"+CObjectFactory::CurrContext + "::" + U::GetName() + "_undef_id_";
       base = CObjectFactory::CurrContext + "__" + U::GetName() + "_undef_id_";
@@ -166,8 +166,40 @@
    bool CObjectFactory::IsGenUId(const StdString& id)
    {
-      const StdString& base = GetUIdBase<U>();
+      const StdString base = GetUIdBase<U>();
       return (id.size() > base.size() && id.compare(0, base.size(), base) == 0);
    }
 
+   template <typename U> 
+   void CObjectFactory::deleteContext(const StdString & context)
+   {
+     for (auto& v : U::AllVectObj[context]) v.reset() ;
+     U::AllVectObj[context].clear() ;
+     U::AllVectObj.erase(context) ; 
+     for (auto& m : U::AllMapObj[context])  m.second.reset() ;
+     U::AllMapObj[context].clear() ;
+     U::AllMapObj.erase(context) ;
+
+     U::GenId.erase(context) ;
+   }
+
+   template <typename U> 
+   void CObjectFactory::deleteAllContexts(void)
+   {
+     list<StdString> contextList ;
+     for(auto& context : U::AllMapObj) contextList.push_back(context.first) ;
+     for(auto& context : contextList) deleteContext<U>(context) ;
+   }
+
+   
+   template <typename U> 
+   void CObjectFactory::dumpObjects(void)
+   {
+     for (auto& context : U::AllMapObj) 
+      for(auto& m : context.second)
+      {
+        info(100)<<"Dump All Object"<<endl ;
+        info(100)<<"Object from context "<<context.first<<" with id "<<m.first<<endl ; 
+      }
+   }
 } // namespace xios
 
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_template.hpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_template.hpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/object_template.hpp	(revision 2265)
@@ -124,6 +124,5 @@
          CObjectTemplate(void);
          explicit CObjectTemplate(const StdString & id);
-         CObjectTemplate(const CObjectTemplate<T> & object,
-                         bool withAttrList = true, bool withId = true);
+         CObjectTemplate(const CObjectTemplate<T> & object, bool withAttrList = true, bool withId = true);
          CObjectTemplate(const CObjectTemplate<T> * const object); // Not implemented.
 
@@ -131,9 +130,6 @@
 
          /// PropriÃ©tÃ©s statiques ///
-         static xios_map<StdString,
-                xios_map<StdString,
-                std::shared_ptr<DerivedType> > > AllMapObj;
-         static xios_map<StdString,
-                std::vector<std::shared_ptr<DerivedType> > > AllVectObj;
+         static xios_map<StdString, xios_map<StdString, std::shared_ptr<DerivedType> > > AllMapObj;
+         static xios_map<StdString, std::vector<std::shared_ptr<DerivedType> > > AllVectObj;
 
          static xios_map< StdString, long int > GenId ;
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/server.cpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/server.cpp	(revision 2264)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/server.cpp	(revision 2265)
@@ -313,5 +313,5 @@
 
 //      MPI_Comm_free(&intraComm);
-
+      CContext::removeAllContexts() ; // free memory for related context 
       CXios::finalizeDaemonsManager();
       
