diff options
author | David CARLIER <devnexen@gmail.com> | 2020-09-29 06:49:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-29 08:49:35 +0300 |
commit | ce8bfc56ad002a3b276249d62038fae4488eae61 (patch) | |
tree | 25b59de4e8c42cae103297018d867b2de532477c /src | |
parent | c2e5546071f18b002fd7e0c222645baef1596089 (diff) | |
download | redis-ce8bfc56ad002a3b276249d62038fae4488eae61.tar.gz |
getting rss size implementation for netbsd (#7293)
Diffstat (limited to 'src')
-rw-r--r-- | src/zmalloc.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/zmalloc.c b/src/zmalloc.c index cefa39aa8..01cb0f917 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -304,6 +304,26 @@ size_t zmalloc_get_rss(void) { return 0L; } +#elif defined(__NetBSD__) +#include <sys/types.h> +#include <sys/sysctl.h> +#include <unistd.h> + +size_t zmalloc_get_rss(void) { + struct kinfo_proc2 info; + size_t infolen = sizeof(info); + int mib[6]; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + mib[4] = sizeof(info); + mib[5] = 1; + if (sysctl(mib, 4, &info, &infolen, NULL, 0) == 0) + return (size_t)info.p_vm_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 |