居民集大小(RSS)限制无效 [英] Resident Set Size (RSS) limit has no effect

查看:84
本文介绍了居民集大小(RSS)限制无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行具有2.6.32-22-通用内核的Ubuntu 10.04的计算机上,会发生以下问题:设置进程的驻留集大小(RSS)的限制似乎没有任何效果.我目前使用以下代码在Python中设置了限制:

The following problem occurs on a machine running Ubuntu 10.04 with the 2.6.32-22-generic kernel: Setting a limit for the Resident Set Size (RSS) of a process does not seem to have any effect. I currently set the limit in Python with the following code:

import resource
# (100, 100) is the (soft, hard) limit. ~100kb.
resource.setrlimit(resource.RLIMIT_RSS, (100, 100))
memory_sink = ['a']*10000000   # this should fail

该列表memory_sink每次都会成功.当我用top检查RSS使用情况时,我可以轻松地获得使用1gb RAM的过程,这意味着限制不起作用. RSS限制不适用于该内核或发行版吗?如果有帮助,resource.RLIMIT_NPROC(用户进程限制)确实可以工作.

The list, memory_sink, succeeds every time. When I check RSS usage with top, I can easily get the process to use 1gb of RAM, which means that the limit is not working. Do RSS limits not work with this kernel or distro? If it helps, resource.RLIMIT_NPROC (user process limit) does work.

推荐答案

形成getrlimit手册页:

Form the getrlimit manpage:

RLIMIT_RSS
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.

Linux内核2.6似乎不支持此功能.

It seems this is just not supported on Linux kernel 2.6.

这篇关于居民集大小(RSS)限制无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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