The machine on which I develop has more memory than the one on which the code will eventually run. I dont have access tothe machine on which it will actually run. This is a 64 bit application and I intend to use the address space but cap physical allocation. I dont want to lock down virtual memory, only physical memory. Is there a way to set limits on a linux machine such that it mimics a system with low RAM. I think ulimit
does not differentiate between reserved address space vs actual allocation. If there is a way to do it without rebooting with different kernel parameters or, pulling out extra RAM that would be great. May be some /proc tricks.
我开发的机器比代码最终运行的机器有更多的内存。我无法使用它实际运行的机器。这是一个64位的应用程序,我打算使用地址空间,但是限制物理分配。我不想锁定虚拟内存,只有物理内存。是否有一种方法可以对linux机器设置限制,使其模仿具有低RAM的系统。我认为ulimit不能区分保留的地址空间和实际的分配。如果有一种方法可以在不使用不同的内核参数的情况下进行重新启动,或者,抽出额外的内存,那就太好了。可能是一些/proc的把戏。
2 个解决方案
#1
1
See https://unix.stackexchange.com/questions/44985/limit-memory-usage-for-a-single-linux-process which suggests using "timeout" from here: https://github.com/pshved/timeout .
参见https://unix.stackexchange.com/questions/44985/limit-memory- use -for-a- linux进程,建议从这里使用“timeout”:https://github.com/pshved/timeout。
#2
1
If You can change boot command line of the kernel and want to restrict available memory use
如果您可以更改内核的引导命令行并希望限制可用内存的使用
mem=
boot parameter.
启动参数。
For more information check:
检查的更多信息:
https://www.kernel.org/doc/Documentation/kernel-parameters.txt
https://www.kernel.org/doc/Documentation/kernel-parameters.txt
#1
1
See https://unix.stackexchange.com/questions/44985/limit-memory-usage-for-a-single-linux-process which suggests using "timeout" from here: https://github.com/pshved/timeout .
参见https://unix.stackexchange.com/questions/44985/limit-memory- use -for-a- linux进程,建议从这里使用“timeout”:https://github.com/pshved/timeout。
#2
1
If You can change boot command line of the kernel and want to restrict available memory use
如果您可以更改内核的引导命令行并希望限制可用内存的使用
mem=
boot parameter.
启动参数。
For more information check:
检查的更多信息:
https://www.kernel.org/doc/Documentation/kernel-parameters.txt
https://www.kernel.org/doc/Documentation/kernel-parameters.txt