|
|
|
|
|
by jmillikin
1375 days ago
|
|
The mlock manual[0] has a "notes" section that provides a good brief summary. The GNU libc manual has more than anyone would ever want to read about memory management, including a section on memory locking[1]. On an intuitive level, think of swap as being a place the kernel can put memory the program has written. When you malloc(4096) and write some bytes into it, the kernel can't evict that page to disk unless there's some swap space to stick it in. However, executables are different because they're already on disk -- the in-memory version is just a cache (everything is cache (computers have too many caches)). The kernel is allowed to drop the copy of the program it has in memory, because it can always read it back from the original executable. [0] https://man7.org/linux/man-pages/man2/mlock.2.html [1] https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_chapter... |
|