source: XIOS3/trunk/src/mem_checker.hpp @ 2418

Last change on this file since 2418 was 2418, checked in by jderouillat, 21 months ago

Integrates a system to log the memory consumption from XIOS init to XIOS finalize, and a HTML webpage to visualize it. The API to use it from models is available too.

  • Property svn:executable set to *
File size: 1.2 KB
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 suspendRSS(void);
16      void resumeRSS(void);
17      void reset(void);
18      double getCumulatedMem(void);
19      static double getMem(void);
20      static double getMemRSS(void);
21      static void logMem( std::string id, bool finalizeLog = false );
22      static CMemChecker& get(std::string name);
23      static std::string getAllCumulatedMem(void) ;
24      static void disable(void) { enabled_=false ;}
25      static void enable(void) {enabled_=true ;}
26      static void release(void) {allMemChecker_.clear();}
27    private:
28      static void check(void) ;
29      double cumulatedMem_;
30      double lastMem_;
31      bool suspended_;
32      std::string name_;
33
34      static std::map<std::string,CMemChecker> allMemChecker_;
35      static CMemChecker dummy_ ;
36      static bool first_ ;
37      static bool enabled_ ;
38
39      static double vsize_init_;
40      static double time_init_;
41  };
42}
43
44
45
46#endif
Note: See TracBrowser for help on using the repository browser.