- 论坛徽章:
- 20
|
这个跟/proc/sys/vm/overcommit_memory的设置有关系。
所谓的overcommit,字面意思是过渡承诺,你这里还有空闲内存么?有呀有呀,尽管用吧。
一种是在申请的时候检查,没有就是没有,不虚报;
一种是在申请的时候统统满足,但用的时候有可能会导致oom。
=============================================================
overcommit_memory:
This value contains a flag that enables memory overcommitment.
When this flag is 0, the kernel attempts to estimate the amount of free memory left when userspace requests more memory.
When this flag is 1, the kernel pretends there is always enough memory until it actually runs out.
When this flag is 2, the kernel uses a "never overcommit" policy that attempts to prevent any overcommit of memory.
This feature can be very useful because there are a lot of programs that malloc() huge amounts of memory "just-in-case" and don't use much of it.
The default value is 0.
See Documentation/vm/overcommit-accounting and security/commoncap.c::cap_vm_enough_memory() for more information.
==============================================================
overcommit_ratio:
When overcommit_memory is set to 2, the committed address space is not permitted to exceed swap plus this percentage of physical RAM. See above. |
|