preface

  • This article was tested under Ubuntu 20.04

Check the cache

fincore

  • See how large an individual file is in the cache

    fincore filename
  • See how big all the files in the directory are in the cache

    ls ./ | xargs fincore

vmtouch

  • See how large an individual file is in the cache

    vmtouch filename
  • See how big all the files in the directory are in the cache

    vmtouch ./

pcstat

  • Not try, https://github.com/tobert/pcstat

hcache

  • Not try, https://github.com/silenceshe…

This article from the
qbit snap

Clear the cache

Only empty PageCache

sync; echo 1 > /proc/sys/vm/drop_caches

Only clear dentries and inodes

sync; echo 2 > /proc/sys/vm/drop_caches

Meanwhile clear PageCache, dentries, and inodes.

sync; echo 3 > /proc/sys/vm/drop_caches 

This article from the
qbit snap