I have a 32GB memory machine and I want to simulate trying out one user process to run inside a 16GB machine. One way is to have a tiny user process run and block 16GB physical memory and then go to sleep and then have this former user process to run in the available system.
The problem is that when I write a program to malloc 16GB memory, most of the memory gets blocked from virtual memory and only around 64MB of physical RAM gets blocked. Is there a way to force block physical RAM?
Linux has a kernel parameter to ignore memory beyond a certain size:
So you could use that. Or look at
mlock