source: XIOS3/branches/xios-3.0-beta/src/mem_checker.hpp @ 2427

Last change on this file since 2427 was 2427, checked in by jderouillat, 17 months ago

Backport the system to log the memory consumption (commit ID [2418-2420,2425-2426])

  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#ifndef __XIOS_MEM_CHECKER_HPP__
2#define __XIOS_MEM_CHECKER_HPP__
3
4#include <string>
5#include <map>
6#include <fstream>
7#include <vector>
8
9namespace xios
10{
11  class CMemChecker
12  {
13    public:
14      CMemChecker(const std::string& name);
15      void suspend(void);
16      void resume(void);
17      void reset(void);
18      std::vector<double> getCumulatedMem(void);
19      static std::vector<double> getMem(void);
20      static std::vector<double> getMemories(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      std::vector<double> cumulatedMem_;
30      std::vector<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 rss_init_;
41      static double vmhwm_init_;
42      static double time_init_;
43      static std::ofstream fout_;
44      static int flush_counter_;
45  };
46}
47
48
49
50#endif
Note: See TracBrowser for help on using the repository browser.