]> git.saurik.com Git - redis.git/commitdiff
Set a 3.5 GB maxmemory limit with noeviction policy if a 32 bit instance without...
authorantirez <antirez@gmail.com>
Thu, 2 Feb 2012 09:17:16 +0000 (10:17 +0100)
committerantirez <antirez@gmail.com>
Thu, 2 Feb 2012 09:26:20 +0000 (10:26 +0100)
src/redis.c

index 8dd35c4ee85981e6118a9081a910fdcd787be191..9f5aa4dbf62c199ff58f17281ca295ec2810bb9f 100644 (file)
@@ -1095,6 +1095,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.cluster_enabled) clusterInit();
     scriptingInit();
     slowlogInit();