Skip to content

Commit d876678

Browse files
committed
Set a 3.5 GB maxmemory limit with noeviction policy if a 32 bit instance without user-provided memory limits is detected.
1 parent 75eaac5 commit d876678

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/redis.c

+10
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,16 @@ void initServer() {
10951095
}
10961096
}
10971097

1098+
/* 32 bit instances are limited to 4GB of address space, so if there is
1099+
* no explicit limit in the user provided configuration we set a limit
1100+
* at 3.5GB using maxmemory with 'noeviction' policy'. This saves
1101+
* useless crashes of the Redis instance. */
1102+
if (server.arch_bits == 32 && server.maxmemory == 0) {
1103+
redisLog(REDIS_WARNING,"Warning: 32 bit instance detected but no memory limit set. Setting 3.5 GB maxmemory limit with 'noeviction' policy now.");
1104+
server.maxmemory = 3584LL*(1024*1024); /* 3584 MB = 3.5 GB */
1105+
server.maxmemory_policy = REDIS_MAXMEMORY_NO_EVICTION;
1106+
}
1107+
10981108
if (server.cluster_enabled) clusterInit();
10991109
scriptingInit();
11001110
slowlogInit();

0 commit comments

Comments
 (0)