为什么ulimit无法成功限制常驻内存,怎么办? [英] Why ulimit can't limit resident memory successfully and how?

查看:144
本文介绍了为什么ulimit无法成功限制常驻内存,怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我启动一个新的bash shell,然后执行:

I start a new bash shell, and execute:

ulimit -m 102400
ulimit -a
"
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 20
file size               (blocks, -f) unlimited
pending signals                 (-i) 16382
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) 102400
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
"

然后,我执行编译一个大项目.链接将使用更大的内存,超过2G.结果,进程ld使用了2G以上的常驻内存.

and then ,I execute compiling a huge project. the Linking of it will use large memory, more then 2G. The result, process ld used more then 2G resident memory.

有什么不对吗?如何使用ulimit或可以使用其他程序来限制常驻内存?

is there any wrong ? how to use ulimit or can I use other programs to limit resident memory?

限制驻留内存的目标,是因为当一个进程几乎用完所有内存时,计算机将冻结.

the target of limit resident memory, is because computer will freeze when one process almost used all memory.

推荐答案

根据

RLIMIT_RSS

指定进程的驻留集的限制(以页为单位)(驻留在RAM中的虚拟页数).此限制仅在Linux 2.4.x中有效,x< 30,并且仅影响对指定MADV_WILLNEED的madvise(2)的调用

Specifies the limit (in pages) of the process's resident set (the number of virtual pages resident in RAM). This limit only has effect in Linux 2.4.x, x < 30, and there only affects calls to madvise(2) specifying MADV_WILLNEED

您可能想通过ulimit -v

这篇关于为什么ulimit无法成功限制常驻内存,怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆