summaryrefslogtreecommitdiff
path: root/src/zmalloc.c
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2019-10-04 13:53:40 +0300
committerOran Agra <oran@redislabs.com>2019-10-04 13:53:40 +0300
commitbf759cc9c3000de05b6591abbfdc9a3450029278 (patch)
tree7a3332b80529bee13ffac991cdabc652d168398e /src/zmalloc.c
parent2e19b941136ebd4e1d9c4766a040d3148a55d24e (diff)
parentee1cef189fff604f165b2d20a307545840de944e (diff)
downloadredis-bf759cc9c3000de05b6591abbfdc9a3450029278.tar.gz
Merge remote-tracking branch 'antirez/unstable' into jemalloc_purge_bg
Diffstat (limited to 'src/zmalloc.c')
-rw-r--r--src/zmalloc.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/zmalloc.c b/src/zmalloc.c
index 437f43b64..e02267fc9 100644
--- a/src/zmalloc.c
+++ b/src/zmalloc.c
@@ -294,6 +294,26 @@ size_t zmalloc_get_rss(void) {
return t_info.resident_size;
}
+#elif defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+#include <unistd.h>
+
+size_t zmalloc_get_rss(void) {
+ struct kinfo_proc info;
+ size_t infolen = sizeof(info);
+ int mib[4];
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PID;
+ mib[3] = getpid();
+
+ if (sysctl(mib, 4, &info, &infolen, NULL, 0) == 0)
+ return (size_t)info.ki_rssize;
+
+ return 0L;
+}
#else
size_t zmalloc_get_rss(void) {
/* If we can't get the RSS in an OS-specific way for this system just