Clear Unused Memory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jmarket
    PCHF Owner
    • Jan 2015
    • 7634

    #1

    Clear Unused Memory

    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 [ICODE]sync[/ICODE] 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:
    [ICODE]sudo sysctl -w vm.drop_caches=3[/ICODE]
    To fully clear unused memory (page cache, inodes, and dentries), run this in Terminal:
    [ICODE]sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches[/ICODE]
    Fedora, CentOS, and any other yum-based distribution:

    To clear only the pagecache, do this in the Terminal:
    [ICODE]echo 1 > /proc/sys/vm/drop_caches[/ICODE]
    To clear dentries and inodes from memory, run this in Terminal:
    [ICODE]echo 2 > /proc/sys/vm/drop_caches[/ICODE]
    To clear everything, including the pagecache, dentries and inodes, run this in Terminal:
    [ICODE]echo 3 > /proc/sys/vm/drop_caches[/ICODE]
Working...