3 ms·
Linux doesn't lie, it is just probably not doing what your simplified view of memory allocation is. On Linux memory allocation is basically assigning range of
by lmilcin 6y ago
Linux doesn't lie, it is just probably not doing what your simplified view of memory allocation is.
On Linux memory allocation is basically assigning range of address that may or may not be backed by pages in physical memory.
This allows doing a lot of interesting and useful stuff.
If you really want the memory for some reason (for example you need to guarantee your operation finishes without running out of memory), you need to touch the pages or force them in some other way (for example using mlock()).
It is just that developers are mostly oblivious how memory management works on Linux and then are surprised that it doesn't exactly do what they want.
Most people I work with can't tell how much memory is available on a Linux box if their life depended on it.
- remexre 6y agoOn my machine, which to my knowledge hasn't had this setting changed, ulimit -l reports each process can only lock 64KiB of memory... I feel like "you should use mlock()" isn't really practical advice.