Ignore:
Timestamp:
05/18/17 17:26:56 (7 years ago)
Author:
ymipsl
Message:

Add "light" memory tracking which must be activated at compile time : make_xios --memtrack light

  • report at info level 10 : max memory consumption and the current memory consumption at the end of exection
  • info at info level 50 : at each timestep, the current memory consumption is printed

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/memtrack.cpp

    r501 r1137  
    4444#include <sstream> 
    4545#include <string> 
     46 
    4647#include <execinfo.h> 
    4748 
     
    5253{ 
    5354  void addr2line(const char *file_name, char** addr, int naddr) ; 
     55#ifdef XIOS_MEMTRACK_LIGHT 
     56  void addr2line(const char *file_name, char** addr, int naddr) {}  
     57#endif 
    5458} 
    5559/* ------------------------------------------------------------ */ 
     
    5963namespace MemTrack 
    6064{ 
     65    size_t currentMemorySize=0 ; 
     66    size_t maxMemorySize=0 ;  
     67 
     68    size_t getCurrentMemorySize(void) {return currentMemorySize; } 
     69    size_t getMaxMemorySize(void) {return maxMemorySize ; } 
    6170 
    6271    /* ------------------------------------------------------------ */ 
     
    375384        // Get the offset to the user chunk and return it. 
    376385        UserChunk *pUser = GetUserAddress(pProlog); 
     386 
     387        currentMemorySize += size ; 
     388        if (currentMemorySize>maxMemorySize) maxMemorySize=currentMemorySize ; 
    377389         
    378390        return pUser; 
     
    400412        // Unlink the block header from the list and destroy it. 
    401413        BlockHeader *pBlockHeader = GetHeaderAddress(pProlog); 
     414        currentMemorySize-=pBlockHeader->GetRequestedSize(); 
    402415        BlockHeader::RemoveNode(pBlockHeader); 
    403416        pBlockHeader->~BlockHeader(); 
Note: See TracChangeset for help on using the changeset viewer.