该应用程序用C语言编写,用g 4.6.3编译.
解决方法
如果被阻止,则虚拟内存不能大于物理RAM交换的大小.如果允许,则虚拟内存可以大于RAM交换.
当您的进程分叉时,您的进程(父进程和子进程)将具有2 * 180GB的虚拟内存(如果您没有交换则太多).
所以,通过这种方式允许过度提交:
echo 1 > /proc/sys/vm/overcommit_memory
如果子进程立即执行,它应该有所帮助,或者在父进程写入太多内存之前释放已分配的内存.所以,要小心,如果两个进程都继续使用所有内存,则内存杀手可能会起作用.
proc(5)的手册页说:
/proc/sys/vm/overcommit_memory
This file contains the kernel virtual
memory accounting mode. Values are: 0: heuristic overcommit (this is
the default) 1: always overcommit,never check 2: always check,never
overcommitIn mode 0,calls of mmap(2) with MAP_NORESERVE are not checked,and
the default check is very weak,leading to the risk of getting a
process “OOM-killed”. Under Linux 2.4 any nonzero value implies mode
1. In mode 2 (available since Linux 2.6),the total virtual address space on the system is limited to (SS + RAM*(r/100)),where SS is the
size of the swap space,and RAM is the size of the physical memory,
and r is the contents of the file /proc/sys/vm/overcommit_ratio.