summaryrefslogtreecommitdiff
path: root/src/zmalloc.c
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2019-07-28 14:33:57 +0100
committerDavid Carlier <devnexen@gmail.com>2019-07-28 14:33:57 +0100
commitf1c6c658ac030b37efe0f9bb17f290c0b647d514 (patch)
tree22246fe88a1d2b74bb89d9706d6eddd23b3494bb /src/zmalloc.c
parent505a855000ef8f1fbea9cb41841fa8708175bba4 (diff)
downloadredis-f1c6c658ac030b37efe0f9bb17f290c0b647d514.tar.gz
Updating resident memory request impl on FreeBSD.
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 5e6010278..fd8bb6938 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