Skip to content
Snippets Groups Projects
Commit 0dcb91d6 authored by Norihiro Watanabe's avatar Norihiro Watanabe
Browse files

make MemWatch class being accessible on any platforms, though it does nothing on Windows and Mac.

parent 1d47d940
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,14 @@ ...@@ -14,7 +14,14 @@
#include "MemWatch.h" #include "MemWatch.h"
#ifndef _MSC_VER #if !defined(WIN32) && !defined(__APPLE__)
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <sys/types.h>
#include <unistd.h>
#endif
namespace BaseLib { namespace BaseLib {
...@@ -25,6 +32,7 @@ MemWatch::MemWatch () ...@@ -25,6 +32,7 @@ MemWatch::MemWatch ()
unsigned MemWatch::updateMemUsage () unsigned MemWatch::updateMemUsage ()
{ {
#if !defined(WIN32) && !defined(__APPLE__)
std::string fname ("/proc/"); std::string fname ("/proc/");
std::stringstream str_pid; std::stringstream str_pid;
str_pid << (unsigned) getpid(); str_pid << (unsigned) getpid();
...@@ -48,6 +56,8 @@ unsigned MemWatch::updateMemUsage () ...@@ -48,6 +56,8 @@ unsigned MemWatch::updateMemUsage ()
in >> pages; in >> pages;
_cmem_size = ((unsigned long) pages) * ((unsigned long) getpagesize()); _cmem_size = ((unsigned long) pages) * ((unsigned long) getpagesize());
in.close (); in.close ();
#endif
return 0; return 0;
} }
...@@ -74,4 +84,3 @@ unsigned long MemWatch::getCodeMemUsage () { ...@@ -74,4 +84,3 @@ unsigned long MemWatch::getCodeMemUsage () {
} // end namespace BaseLib } // end namespace BaseLib
#endif // _MSC_VER
...@@ -15,15 +15,6 @@ ...@@ -15,15 +15,6 @@
#ifndef MEMWATCH_H_ #ifndef MEMWATCH_H_
#define MEMWATCH_H_ #define MEMWATCH_H_
#ifndef _MSC_VER
#include <sys/types.h>
#include <unistd.h>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
namespace BaseLib { namespace BaseLib {
class MemWatch { class MemWatch {
...@@ -36,14 +27,12 @@ public: ...@@ -36,14 +27,12 @@ public:
private: private:
unsigned updateMemUsage (); unsigned updateMemUsage ();
unsigned long _vmem_size; unsigned long _vmem_size = 0;
unsigned long _rmem_size; unsigned long _rmem_size = 0;
unsigned long _smem_size; unsigned long _smem_size = 0;
unsigned long _cmem_size; unsigned long _cmem_size = 0;
}; };
} }
#endif // not Windows
#endif /* MEMWATCH_H_ */ #endif /* MEMWATCH_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment