I came across this link and apparently it’s possible to flush memory in linux form the command line.
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches
sync
Are these commands safe? Anyone have any experience?
Thanks!
1 Like
/proc/sys/vm/drop_caches
…
Use of this file can cause performance problems. Since it discards cached objects, it may cost a significant amount of I/O and CPU to recreate the dropped objects, especially if they were under heavy use. Because of this, use outside of a testing or debugging environment is not recommended.
Kernel Docs (1) also says:
To increase the number of objects freed by this operation, the user may run sync prior to writing to /proc/sys/vm/drop_caches. This will minimize the number of dirty objects on the system and create more candidates to be dropped.
While there might be use cases to do so (big compiling project, etc); IMO doing this arbitrarily is just wasting your RAM-the OS will clear the caches as needed.
(1) Documentation for /proc/sys/vm/ — The Linux Kernel documentation
3 Likes