overcommit_memory

简介:

今天在一台机器上查看java进行时,运行jps -m时报如下错误:

1
2
3
Error occurred during initialization of VM
Could not reserve enough space  for  object heap
Could not create the Java virtual machine.
但其实服务器的内存是充足的:
1
2
3
4
5
free  -m
              total       used        free      shared    buffers     cached
Mem:         64412      27418      36994          0        174      13226
-/+ buffers /cache :      14018      50394
Swap:            0          0          0
这其实是由于一个系统的参数导致:
vm.overcommit_memory
这个可以用来控制对应用分配内存的限制,默认是0,关于这个参数
1
2
3
4
5
6
7
8
9
10
11
0 — The default setting. The kernel performs heuristic memory overcommit
handling by estimating the amount of memory available and failing requests
that are blatantly invalid. Unfortunately, since memory is allocated using
a heuristic rather than a precise algorithm, this setting can sometimes allow
available memory on the system to be overloaded.
1 — The kernel performs no memory overcommit handling. Under this setting,
the potential  for  memory overload is increased, but so is performance  for
memory-intensive tasks.
2 — The kernel denies requests  for  memory equal to or larger than the  sum  of
total available swap and the percentage of physical RAM specified  in  overcommit_ratio.
This setting is best  if  you want a lesser risk of memory overcommitment.

可以看出2是比较严格的限制,1是最宽松的限制,对于不同的应用对这个参数的要求页不一样。

比如对于greenplum来说,是不允许使用swap的,所以参数要设置为2.
而对于redis应用,因为在bgsave的时候,需要2倍的使用内存,所以建议设置为1.
java的应用设置为0或1都是可以的。


本文转自菜菜光 51CTO博客,原文链接:http://blog.51cto.com/caiguangguang/1395596,如需转载请自行联系原作者
目录
打赏
0
0
0
0
69
分享
相关文章
Codeforce 712A Memory and Crow
A. Memory and Crow time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output There are n integers b1, b2, .
688 0
又一次内存分配失败(关于overcommit_memory)
1、问题现象和分析: 测试时发现当系统中空闲内存还有很多时,就报内存分配失败了,所有进程都报内存分配失败:sshd@localhost:/var/log>free              total       used       free     shared    buf...
1406 0
ZCMU - 2018: Memory leak
ZCMU - 2018: Memory leak
140 0

热门文章

最新文章