feat(util/memory): implement get_current_rss using the jemalloc API

This commit is contained in:
Gabriel Ebner 2017-03-14 08:10:17 +01:00
parent c5c0a74d77
commit e35968cda1

View file

@ -15,7 +15,27 @@ Author: Leonardo de Moura
#define LEAN_CHECK_MEM_THRESHOLD 200
#endif
#if defined(LEAN_WINDOWS)
#if defined(HAS_JEMALLOC)
#include <jemalloc/jemalloc.h>
namespace lean {
size_t get_peak_rss() {
size_t allocated;
size_t sz = sizeof(size_t);
if (mallctl("stats.allocated", &allocated, &sz, NULL, 0) == 0) {
return allocated;
} else {
return 0;
}
}
size_t get_current_rss() {
return get_peak_rss();
}
}
#elif defined(LEAN_WINDOWS)
/* ----------------------------------------------------
Windows version for get_peak_rss and get_current_rss
--------------------------------------------------- */