该应用程序用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.
原文地址:https://www.jb51.cc/linux/394309.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。