Ignore:
Timestamp:
11/25/21 18:25:19 (3 years ago)
Author:
ymipsl
Message:

tracking memory leak : remove context and all related object from object factory when context is finalized.
YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/object_factory_impl.hpp

    r2183 r2265  
    147147 
    148148   template <typename U> 
    149    const StdString& CObjectFactory::GetUIdBase(void) 
    150    { 
    151       static StdString base ;  
     149   const StdString CObjectFactory::GetUIdBase(void) 
     150   { 
     151      StdString base ;  
    152152//      base = "__"+CObjectFactory::CurrContext + "::" + U::GetName() + "_undef_id_"; 
    153153      base = CObjectFactory::CurrContext + "__" + U::GetName() + "_undef_id_"; 
     
    166166   bool CObjectFactory::IsGenUId(const StdString& id) 
    167167   { 
    168       const StdString& base = GetUIdBase<U>(); 
     168      const StdString base = GetUIdBase<U>(); 
    169169      return (id.size() > base.size() && id.compare(0, base.size(), base) == 0); 
    170170   } 
    171171 
     172   template <typename U>  
     173   void CObjectFactory::deleteContext(const StdString & context) 
     174   { 
     175     for (auto& v : U::AllVectObj[context]) v.reset() ; 
     176     U::AllVectObj[context].clear() ; 
     177     U::AllVectObj.erase(context) ;  
     178     for (auto& m : U::AllMapObj[context])  m.second.reset() ; 
     179     U::AllMapObj[context].clear() ; 
     180     U::AllMapObj.erase(context) ; 
     181 
     182     U::GenId.erase(context) ; 
     183   } 
     184 
     185   template <typename U>  
     186   void CObjectFactory::deleteAllContexts(void) 
     187   { 
     188     list<StdString> contextList ; 
     189     for(auto& context : U::AllMapObj) contextList.push_back(context.first) ; 
     190     for(auto& context : contextList) deleteContext<U>(context) ; 
     191   } 
     192 
     193    
     194   template <typename U>  
     195   void CObjectFactory::dumpObjects(void) 
     196   { 
     197     for (auto& context : U::AllMapObj)  
     198      for(auto& m : context.second) 
     199      { 
     200        info(100)<<"Dump All Object"<<endl ; 
     201        info(100)<<"Object from context "<<context.first<<" with id "<<m.first<<endl ;  
     202      } 
     203   } 
    172204} // namespace xios 
    173205 
Note: See TracChangeset for help on using the changeset viewer.