Limits and privileges

A privileged process, either by running as root, or, better yet, by having the CAP_IPC_LOCK capability bit set in order to lock memory (we shall describe process credentials and capabilities in detail in their own chapters - Chapter 7, Process Credentials, and Chapter 8, Process Capabilities), can lock unlimited amounts of memory.

From Linux 2.6.9 onward, for a non-privileged process, it is limited by the RLIMIT_MEMLOCK soft resource limit (which, typically, is not set very high). Here is an example on an x86_64 Fedora box (as well as Ubuntu):

$ prlimit | grep MEMLOCKMEMLOCK   max locked-in-memory address space   65536   65536 bytes$ 

It's just 64 KB (ditto on an embedded ARM Linux, by default).

At the time of writing this ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.