Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于setrlimit #43

Open
kidting opened this issue Aug 10, 2020 · 2 comments
Open

关于setrlimit #43

kidting opened this issue Aug 10, 2020 · 2 comments

Comments

@kidting
Copy link

kidting commented Aug 10, 2020

image
为什么这里内存需要乘2呢

@kidting
Copy link
Author

kidting commented Aug 10, 2020

另外想请教一下,我用judger跑一个go程序测试,首先不做限制,judger给出其memory值假设为X,之后我将10 * X作为--max_memory参数,由于memory限制go程序跑不起来,想问问为什么setrlimit设置的资源限制和wait4统计的资源有这么大差异呢?另外同样的测试在C/C++程序上是没问题的

@virusdefender
Copy link
Contributor

  1. 为了避免代码是正确的,但是因为超过内存 oom 而被判定为 re。如果程序占用低于两倍,最后再重新检查内存占用和配置的关系,就可以判定为超内存而不是 re,如果超过两倍,那就真的 re 了(可能会被 kill)。

  2. 对于 go / Java 等带虚拟机的高级一些的语言,因为它们会根据物理内存来预先分配内存而无法感知到存在内存限制,导致分配失败(Java 新版可以感知到 cgroup,但是这里并没用这个技术)。直接限制就会导致一些无法启动的问题。
    建议使用 memory_limit_check_only,也就是不实际进行内存限制,而是只看最终内存使用的数字来判定结果,和问题 1 也有些关系。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants