diff --git a/src/object.c b/src/object.c index a5705ea5a..2e27d69f6 100644 --- a/src/object.c +++ b/src/object.c @@ -537,9 +537,9 @@ void dismissObject(robj *o, size_t size_hint) { /* madvise(MADV_DONTNEED) may not work if Transparent Huge Pages is enabled. */ if (server.thp_enabled) return; - /* Currently we use zmadvise_dontneed only when we use jemalloc. + /* Currently we use zmadvise_dontneed only when we use jemalloc with Linux. * so we avoid these pointless loops when they're not going to do anything. */ -#if defined(USE_JEMALLOC) +#if defined(USE_JEMALLOC) && defined(__linux__) if (o->refcount != 1) return; switch(o->type) { case OBJ_STRING: dismissStringObject(o); break; diff --git a/src/server.c b/src/server.c index 301e21e28..3a4a1c3cc 100644 --- a/src/server.c +++ b/src/server.c @@ -5987,9 +5987,9 @@ void dismissMemoryInChild(void) { /* madvise(MADV_DONTNEED) may not work if Transparent Huge Pages is enabled. */ if (server.thp_enabled) return; - /* Currently we use zmadvise_dontneed only when we use jemalloc. + /* Currently we use zmadvise_dontneed only when we use jemalloc with Linux. * so we avoid these pointless loops when they're not going to do anything. */ -#if defined(USE_JEMALLOC) +#if defined(USE_JEMALLOC) && defined(__linux__) /* Dismiss replication backlog. */ if (server.repl_backlog != NULL) { diff --git a/src/zmalloc.c b/src/zmalloc.c index 012dadd2f..b68f6b46a 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -346,7 +346,7 @@ void zmalloc_set_oom_handler(void (*oom_handler)(size_t)) { * We do that in a fork child process to avoid CoW when the parent modifies * these shared pages. */ void zmadvise_dontneed(void *ptr) { -#if defined(USE_JEMALLOC) +#if defined(USE_JEMALLOC) && defined(__linux__) static size_t page_size = 0; if (page_size == 0) page_size = sysconf(_SC_PAGESIZE); size_t page_size_mask = page_size - 1;