Redis在启动的时候会报如下WARNING:
WARNING overcommit_memory is set to 0! Background save may failunder low memory condition.
To fix this issue add 'vm.overcommit_memory = 1'to /etc/sysctl.conf and then reboot or run the command 'sysctlvm.overcommit_memory=1' for this to take effect.
java -Xmx20g -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
但是给10g的时候就OK
java -Xmx10g -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)
内存明明是够的,后来发现在这台服务器上overcommit_memory被设置了2:
cat /proc/meminfo |grep -i commit
CommitLimit(=memory*overcommit_ratio+swap):49744512 kB
Committed_AS: 33947660 kB
从上面可知只能再分配不到14GB的空间,因此也就解释了上面的这个错误,后改成0解决;
本文转自MIKE老毕 51CTO博客,原文链接:http://blog.51cto.com/boylook/1299870,如需转载请自行联系原作者