Knowing how to clear unused RAM in *nix is very useful. This quick guide will show you the commands needed to clear unused memory in all flavors of Linux.
NOTE: WE HIGHLY RECOMMEND USING
before doing this to ensure that dirty objects are freeable. Otherwise, running these commands may not yield the full benefit.
Debian, Ubuntu, and any other aptitude-based distribution:
To clear caches, simply run this in Terminal:
To fully clear unused memory (page cache, inodes, and dentries), run this in Terminal:
Fedora, CentOS, and any other yum-based distribution:
To clear only the pagecache, do this in the Terminal:
To clear dentries and inodes from memory, run this in Terminal:
To clear everything, including the pagecache, dentries and inodes, run this in Terminal:
NOTE: WE HIGHLY RECOMMEND USING
Code:
sync
Debian, Ubuntu, and any other aptitude-based distribution:
To clear caches, simply run this in Terminal:
Code:
sudo sysctl -w vm.drop_caches=3
To fully clear unused memory (page cache, inodes, and dentries), run this in Terminal:
Code:
sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
Fedora, CentOS, and any other yum-based distribution:
To clear only the pagecache, do this in the Terminal:
Code:
echo 1 > /proc/sys/vm/drop_caches
To clear dentries and inodes from memory, run this in Terminal:
Code:
echo 2 > /proc/sys/vm/drop_caches
To clear everything, including the pagecache, dentries and inodes, run this in Terminal:
Code:
echo 3 > /proc/sys/vm/drop_caches