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

关于内存限制的问题 #8

Closed
FlyingOnion opened this issue Apr 1, 2017 · 3 comments
Closed

关于内存限制的问题 #8

FlyingOnion opened this issue Apr 1, 2017 · 3 comments

Comments

@FlyingOnion
Copy link

你好,我想问下child.c 45行
max_memory.rlim_cur = max_memory.rlim_max = (rlim_t) (_config->max_memory) * 2;
乘2是什么原因?

@virusdefender
Copy link
Contributor

因为有时候限制内存太小的话,进程可能启动都有问题,所以可以使用的内存限制大一些,最后超内存是按照实际获取到的用量数字来的。

@FlyingOnion
Copy link
Author

我自己也写了一个类似的,用hello world测试,显示子进程的ru_maxrss是444KB,但rlimit至少要设置4MB才能运行,否则会报a.out: error while loading shared libraries: libc.so.6: failed to map segment from shared object: Cannot allocate memory,这是正常的情况吗?

@virusdefender
Copy link
Contributor

@FlyingOnion 因为 maxrss 不算动态库之类的内存吧,而 rlimit_as 太小的话,可能会影响进程初始化和库的加载。

RSS is the Resident Set Size and is used to show how much memory is allocated to that process and is in RAM. It does not include memory that is swapped out. It does include memory from shared libraries as long as the pages from those libraries are actually in memory. It does include all stack and heap memory.

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