OGS
BaseLib::MemWatch Class Reference

Detailed Description

Definition at line 19 of file MemWatch.h.

#include <MemWatch.h>

Public Member Functions

 MemWatch ()
 
unsigned long getVirtMemUsage ()
 

Private Member Functions

unsigned updateMemUsage ()
 

Private Attributes

unsigned long vmem_size_ = 0
 

Constructor & Destructor Documentation

◆ MemWatch()

BaseLib::MemWatch::MemWatch ( )

Definition at line 28 of file MemWatch.cpp.

29{
31}
unsigned updateMemUsage()
Definition MemWatch.cpp:33

References updateMemUsage().

Member Function Documentation

◆ getVirtMemUsage()

unsigned long BaseLib::MemWatch::getVirtMemUsage ( )

Definition at line 59 of file MemWatch.cpp.

60{
62 return vmem_size_;
63}
unsigned long vmem_size_
Definition MemWatch.h:27

References updateMemUsage(), and vmem_size_.

Referenced by main().

◆ updateMemUsage()

unsigned BaseLib::MemWatch::updateMemUsage ( )
private

Definition at line 33 of file MemWatch.cpp.

34{
35#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__MINGW32__)
36 std::string fname("/proc/");
37 std::stringstream str_pid;
38 str_pid << static_cast<unsigned>(getpid());
39 fname += str_pid.str();
40 fname += "/statm";
41 unsigned pages;
42
43 std::ifstream in(fname.c_str(), std::ios::in);
44 if (!in.is_open())
45 {
46 perror("open");
47 return 1;
48 }
49
50 in >> pages;
51 vmem_size_ = static_cast<unsigned long>(pages) *
52 static_cast<unsigned long>(getpagesize());
53 in.close();
54#endif
55
56 return 0;
57}

References vmem_size_.

Referenced by MemWatch(), and getVirtMemUsage().

Member Data Documentation

◆ vmem_size_

unsigned long BaseLib::MemWatch::vmem_size_ = 0
private

Definition at line 27 of file MemWatch.h.

Referenced by getVirtMemUsage(), and updateMemUsage().


The documentation for this class was generated from the following files: