linux的overcmmit特性,其实就是OOMK(Out Of Memory Killer)
写个简单程序在嵌入式上跑,以此来认识overcommit的特性:
#include#includeint main(void)
{
int i;
char *p;
for (i=0; i/proc/sys/vm/ overcommit_ratio
运行结果为能分配到99MB
malloc 1MB[98]
malloc 1MB[99]
malloc fail[100]
参考:
Linux下OOM Killer机制详解
http://blog.dccmx.com/2011/04/oom-killer-on-linux/ |