diff --git a/src/object.c b/src/object.c index f9122b741..3d747ea3a 100644 --- a/src/object.c +++ b/src/object.c @@ -856,8 +856,10 @@ void dismissGCRAObject(robj *o, size_t size_hint) { * it can reduce unnecessary iteration for complex data types that are probably * not going to release any memory. */ 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; + /* madvise(MADV_DONTNEED) may not work if Transparent Huge Pages is enabled. + * Strings use sdsfree() which doesn't depend on madvise, so skip this + * check for them. */ + if (server.thp_enabled && o->type != OBJ_STRING) return; /* 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. */