2013-04-16 23:57:37 -04:00
|
|
|
#include <toku_portability.h>
|
2013-04-16 23:57:27 -04:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <inttypes.h>
|
2013-04-16 23:57:28 -04:00
|
|
|
#include <toku_os.h>
|
2013-04-16 23:57:27 -04:00
|
|
|
|
|
|
|
#define DO_MEMORY_INFO 1
|
|
|
|
|
|
|
|
#if DO_MEMORY_INFO
|
|
|
|
#include <psapi.h>
|
|
|
|
|
|
|
|
static int
|
|
|
|
get_memory_info(PROCESS_MEMORY_COUNTERS *meminfo) {
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = GetProcessMemoryInfo(GetCurrentProcess(), meminfo, sizeof *meminfo);
|
|
|
|
if (r == 0)
|
|
|
|
return GetLastError();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int
|
2013-04-16 23:57:28 -04:00
|
|
|
toku_os_get_rss(int64_t *rss) {
|
2013-04-16 23:57:27 -04:00
|
|
|
int r;
|
|
|
|
#if DO_MEMORY_INFO
|
|
|
|
PROCESS_MEMORY_COUNTERS meminfo;
|
|
|
|
|
|
|
|
r = get_memory_info(&meminfo);
|
|
|
|
if (r == 0)
|
|
|
|
*rss = meminfo.WorkingSetSize;
|
|
|
|
#else
|
|
|
|
r = 0;
|
|
|
|
*rss = 0;
|
|
|
|
#endif
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-04-16 23:57:28 -04:00
|
|
|
toku_os_get_max_rss(int64_t *maxrss) {
|
2013-04-16 23:57:27 -04:00
|
|
|
int r;
|
|
|
|
#if DO_MEMORY_INFO
|
|
|
|
PROCESS_MEMORY_COUNTERS meminfo;
|
|
|
|
|
|
|
|
r = get_memory_info(&meminfo);
|
|
|
|
if (r == 0)
|
|
|
|
*maxrss = meminfo.PeakWorkingSetSize;
|
|
|
|
#else
|
|
|
|
r = 0;
|
|
|
|
*maxrss = 0;
|
|
|
|
#endif
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|