vmtouch The Virtual Memory Toucher

TL;DR

Everyone loves touch.

vmtouch is the virtual memory toucher, portable file system cache diagnostics and control.

main()

OS kernel takes care of filesystem cache, generated from read / write. However, users don’t have much fine-grained control over what files / directories to cache / drop when more memory is needed to run new applications.

Take the Linux kernel exposes /proc/sys/vm/drop_caches for privileged users to signal the kernel to drop clean caches, as well as reclaimable slab objects like dentries and inodes to free up memory.

You only do

  1. free pagecache
    echo 1 > /proc/sys/vm/drop_caches
  2. free reclaimable slab objects (includes dentries and inodes)
    echo 2 > /proc/sys/vm/drop_caches
  3. free slack objects and page cache
    echo 3 | sudo tee /proc/sys/vm/drop_caches

See Documentation sysctl/vm.txt for more info.

vmtouch offers more flexible and granular control over what files, directories (can be recursive) to load into memory. It is also possible to evict files from the cache.

Files loaded by vmtouch get locked into memory and stay there until system is restarted or vmtouch is terminated. It’s fun to use.

Keep in mind that the poweer of shooting yourself in the foot is in your own hands. Use it wisely and carefully.

NOTE: vmtouch is for page cache. If you are looking for solution to manage browser profile(s) in tmpfs / ramfs and periodically sync back to disk, take a U-turn and look at profile-sync-daemon AKA psd .

EOF