summaryrefslogtreecommitdiff
path: root/src/zmalloc.c
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2022-01-16 08:03:09 +0000
committerGitHub <noreply@github.com>2022-01-16 10:03:09 +0200
commit50fa627b90cfcd322ed92c9ab3dc13ea87bc6b34 (patch)
tree7aa8c619cbdb9da1794de4b95a8e0b28886c3ab6 /src/zmalloc.c
parent32e7b46a17601be33ea687ad5bafc6f01fcb8891 (diff)
downloadredis-50fa627b90cfcd322ed92c9ab3dc13ea87bc6b34.tar.gz
zmalloc_get_rss netbsd impl fix proposal. (#10116)
Seems like the previous implementation was broken (always returning 0) since kinfo_proc2 is used the KERN_PROC2 sysctl oid is more appropriate and also the query's length was not necessarily accurate (6 here).
Diffstat (limited to 'src/zmalloc.c')
-rw-r--r--src/zmalloc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/zmalloc.c b/src/zmalloc.c
index 0dd4c9836..6ea2ab41b 100644
--- a/src/zmalloc.c
+++ b/src/zmalloc.c
@@ -476,12 +476,12 @@ size_t zmalloc_get_rss(void) {
size_t infolen = sizeof(info);
int mib[6];
mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
+ mib[1] = KERN_PROC2;
mib[2] = KERN_PROC_PID;
mib[3] = getpid();
mib[4] = sizeof(info);
mib[5] = 1;
- if (sysctl(mib, 4, &info, &infolen, NULL, 0) == 0)
+ if (sysctl(mib, __arraycount(mib), &info, &infolen, NULL, 0) == 0)
return (size_t)info.p_vm_rssize * getpagesize();
return 0L;