summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2012-02-02 10:17:16 +0100
committerantirez <antirez@gmail.com>2012-02-02 10:17:21 +0100
commit1cd0cdd523b50ccbfeb5c76784e8fb76a05ddcb2 (patch)
tree7014b3ce40f65814530d88119cf5f139eb1f18ab
parentf373061563e75cf70acc6ead8b8c1727172f7547 (diff)
downloadredis-1cd0cdd523b50ccbfeb5c76784e8fb76a05ddcb2.tar.gz
Set a 3.5 GB maxmemory limit with noeviction policy if a 32 bit instance without user-provided memory limits is detected.
-rw-r--r--src/redis.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/redis.c b/src/redis.c
index 4de9203d4..c8904e84b 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -985,6 +985,16 @@ void initServer() {
}
}
+ /* 32 bit instances are limited to 4GB of address space, so if there is
+ * no explicit limit in the user provided configuration we set a limit
+ * at 3.5GB using maxmemory with 'noeviction' policy'. This saves
+ * useless crashes of the Redis instance. */
+ if (server.arch_bits == 32 && server.maxmemory == 0) {
+ redisLog(REDIS_WARNING,"Warning: 32 bit instance detected but no memory limit set. Setting 3.5 GB maxmemory limit with 'noeviction' policy now.");
+ server.maxmemory = 3584LL*(1024*1024); /* 3584 MB = 3.5 GB */
+ server.maxmemory_policy = REDIS_MAXMEMORY_NO_EVICTION;
+ }
+
if (server.vm_enabled) vmInit();
slowlogInit();
bioInit();