When operating on large amount of files (10000+) cache size can grow up to hundreds of MB. As page cache priority is lower than a processes memory priority, it is freed from time to time. Or You can free it on your own.
# flush file system buffers (cache > disk) sudo sync # free page cache sudo -s "echo 1 > /proc/sys/vm/drop_caches" # free inodes and dentries cache sudo -s "echo 2 > /proc/sys/vm/drop_caches" # free page cache, inodes and dentries cache sudo -s "echo 3 > /proc/sys/vm/drop_caches"
Note the sync command. Page cache also caches write operations. When you save a file that's already caches, content is saved into the cache and real disk write operation happens later in some batch. Such cached object/page is called dirty and can't be freed. To force the disk write of all dirty pages and make them freeable, use sync before.