c - In a POSIX unix system, is it possible to mmap() a file in such a way that it will never be swapped out to disk in favor of other files? -


if not using mmap(), seems there should way give files "priority", time they're swapped out page faults trying bring in, e.g., executing code, or memory malloc()'d process, never other files. 1 can think of situations useful. consider search engines, should keep index files in cache, may simultaneously writing new files (not being used search).

there few ways.

the best way madvise(), allows inform kernel need particular range of memory soon, gives priority on other memory. can use particular range not needed soon, should swapped out sooner.

the hack way mlock(), forces range of memory stay in ram. not idea, , should used in special cases. common case store passwords in ram password cannot recovered swap file after computer powered off. not use mlock() performance tuning unless had exhausted other options.

the worst way poke memory, forcing stay fresh.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -