This is as much a question about suspending processes/SIGSTOP as it is about stress
So I'm using stress to simulate memory pressure on my system.
stress --vm X --vm-bytes YM
This works fine, but I notice that it consumes a lot of CPU.
root@ET0021B703EB23:~# ps -aux | grep stress
root 11800 0.0 0.0 2192 232 pts/4 S+ 15:21 0:00 stress --vm 1 --vm-bytes 10M
root 11801 83.5 0.2 12436 2436 pts/4 R+ 15:21 0:03 stress --vm 1 --vm-bytes 10M
Now CPU load isn't something I want to be concerned about in this test. I used Ctrl + Z to suspend my stress
, and I now see that the CPU consumed has fallen but the memory remains, which is what I wanted.
root@ET0021B703EB23:~# ps -aux | grep stress
root 9080 0.0 0.0 2760 296 pts/2 S+ 15:18 0:00 grep stress
root 17030 0.0 0.0 2192 172 pts/2 T 14:51 0:00 stress --vm 1 --vm-bytes 10M
root 17031 2.7 0.4 12436 4860 pts/2 T 14:51 0:44 stress --vm 1 --vm-bytes 10M
As I understand it, keeping a process suspended will keep it in memory. Can I therefore use this method to reliably simulate memory pressure without CPU cost?
My concern is if there is something in linux that will kill, or otherwise remove the memory impact of, a suspended process under memory pressure or something (like Android's lowmemorykiller). Does such a thing exist, or is there any reason why this wouldn't work?