source: XIOS/dev/dev_ym/XIOS_COUPLING/src/mem_checker.hpp @ 2230

Last change on this file since 2230 was 2212, checked in by ymipsl, 3 years ago

Revisiting Memory tracking :

  • MemTrack? has been improved
    • Not need anymore to use private external libaddr2line, fork addr2line process internaly and use bidrectionnale pipe to send stack adress et get in return the demangle stack name
    • Can use cxa_demangle in backup
  • Block memory leak report is output in separate file (xios_xxx.mem),memory block are ordonned in decreasing size.
  • Possibility to output only the n bigest bloc with : "memtrack_blocs" xios parameters
  • Possibility to output only bloc over a given size with : "memtrack_size" xios parameters
  • Implement new method to retrieve the memory consumed in a time interval very similarely to xios timer :

CMemTracker("xios").resume()
CMemTracker("xios").suspend() ;
etc....

YM

  • Property svn:executable set to *
File size: 898 bytes
Line 
1#ifndef __XIOS_MEM_CHECKER_HPP__
2#define __XIOS_MEM_CHECKER_HPP__
3
4#include <string>
5#include <map>
6
7namespace xios
8{
9  class CMemChecker
10  {
11    public:
12      CMemChecker(const std::string& name);
13      void suspend(void);
14      void resume(void);
15      void reset(void);
16      double getCumulatedMem(void);
17      static double getMem(void);
18      static CMemChecker& get(std::string name);
19      static std::string getAllCumulatedMem(void) ;
20      static void disable(void) { enabled_=false ;}
21      static void enable(void) {enabled_=true ;}
22    private:
23      static void check(void) ;
24      double cumulatedMem_;
25      double lastMem_;
26      bool suspended_;
27      std::string name_;
28
29      static std::map<std::string,CMemChecker> allMemChecker_;
30      static CMemChecker dummy_ ;
31      static bool first_ ;
32      static bool enabled_ ;
33  };
34}
35
36
37
38#endif
Note: See TracBrowser for help on using the repository browser.