Last change
on this file since 2420 was
2420,
checked in by jderouillat, 21 months ago
|
Add an option (log_memory : set to false by default), to activate memory monitoring. Logs are now buffered.
|
-
Property svn:executable set to
*
|
File size:
1.3 KB
|
Rev | Line | |
---|
[2212] | 1 | #ifndef __XIOS_MEM_CHECKER_HPP__ |
---|
| 2 | #define __XIOS_MEM_CHECKER_HPP__ |
---|
| 3 | |
---|
| 4 | #include <string> |
---|
| 5 | #include <map> |
---|
[2420] | 6 | #include <fstream> |
---|
[2212] | 7 | |
---|
| 8 | namespace xios |
---|
| 9 | { |
---|
| 10 | class CMemChecker |
---|
| 11 | { |
---|
| 12 | public: |
---|
| 13 | CMemChecker(const std::string& name); |
---|
| 14 | void suspend(void); |
---|
| 15 | void resume(void); |
---|
[2418] | 16 | void suspendRSS(void); |
---|
| 17 | void resumeRSS(void); |
---|
[2212] | 18 | void reset(void); |
---|
| 19 | double getCumulatedMem(void); |
---|
| 20 | static double getMem(void); |
---|
[2418] | 21 | static double getMemRSS(void); |
---|
| 22 | static void logMem( std::string id, bool finalizeLog = false ); |
---|
[2212] | 23 | static CMemChecker& get(std::string name); |
---|
| 24 | static std::string getAllCumulatedMem(void) ; |
---|
| 25 | static void disable(void) { enabled_=false ;} |
---|
| 26 | static void enable(void) {enabled_=true ;} |
---|
[2274] | 27 | static void release(void) {allMemChecker_.clear();} |
---|
[2212] | 28 | private: |
---|
| 29 | static void check(void) ; |
---|
| 30 | double cumulatedMem_; |
---|
| 31 | double lastMem_; |
---|
| 32 | bool suspended_; |
---|
| 33 | std::string name_; |
---|
| 34 | |
---|
| 35 | static std::map<std::string,CMemChecker> allMemChecker_; |
---|
| 36 | static CMemChecker dummy_ ; |
---|
| 37 | static bool first_ ; |
---|
| 38 | static bool enabled_ ; |
---|
[2418] | 39 | |
---|
| 40 | static double vsize_init_; |
---|
| 41 | static double time_init_; |
---|
[2420] | 42 | static std::ofstream fout_; |
---|
| 43 | static int flush_counter_; |
---|
[2212] | 44 | }; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.