Ubuntu 系统缓存的查看与清空(qbit)

前言

  • 本文在 Ubuntu 20.04 下测试

查看缓存

fincore

  • 查看单个文件有多大在缓存中node

    fincore filename
  • 查看目录下全部文件有多大在缓存中git

    ls ./ | xargs fincore

vmtouch

  • 查看单个文件有多大在缓存中github

    vmtouch filename
  • 查看目录下全部文件有多大在缓存中shell

    vmtouch ./

pcstat

hcache

本文出自 qbit snap

清空缓存

只清空 PageCache

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

只清空 dentries 和 inodes

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

同时清空 PageCache, dentries 和 inodes.

sync; echo 3 > /proc/sys/vm/drop_caches
本文出自 qbit snap