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,如需转载请自行联系原作者
相关文章
|
存储 运维 监控
深入Linux核心:文件系统与日志解析
【8月更文挑战第20天】
241 2
|
JavaScript 前端开发 测试技术
写给不耐烦程序员的 JavaScript 指南(三)
写给不耐烦程序员的 JavaScript 指南(三)
100 0
|
编解码 固态存储 数据挖掘
通俗解读人脸检测框架-RetinaFace
通俗解读人脸检测框架-RetinaFace
385 2
|
人工智能 Java C++
python入门(五) vscode配置Anaconda 环境,代码自动提示
python入门(五) vscode配置Anaconda 环境,代码自动提示
1006 0
|
Dubbo Cloud Native Java
带你读《Apache Dubbo微服务开发从入门到精通》—— 一、 平滑升级到Dubbo3版本(上)
带你读《Apache Dubbo微服务开发从入门到精通》—— 一、 平滑升级到Dubbo3版本(上)
328 84
|
SQL 前端开发 JavaScript
基于python的租房网站-房屋出租租赁系统(python+django+vue)
该项目是基于python/django/vue开发的房屋租赁系统/租房平台,作为本学期的课程作业作品。欢迎大家提出宝贵建议。
454 1
|
前端开发 数据库
人事管理项目-员工资料模块
人事管理项目-员工资料模块
人事管理项目-员工资料模块
|
存储 编译器 区块链
NFT质押分红dapp系统开发模式智能合约定制详情
NFT质押分红dapp系统开发模式智能合约定制详情
|
JSON 前端开发 API
后端API接口标准定义
后端API接口标准定义
149 0
|
关系型数据库 分布式数据库 PolarDB
5.18.1PolarDB课后作业
5.18.1PolarDB课后作业
209 0