Clearing Memory (RAM) Cache on CentOS

10,816

You don't need to do this. Linux will drop all caches if it needs the RAM for other purposes. See http://www.linuxatemyram.com/ and Why is Linux reporting "free" memory strangely? for more information.

Share:
10,816

Related videos on Youtube

user3650841
Author by

user3650841

Updated on September 18, 2022

Comments

  • user3650841
    user3650841 over 1 year

    I know this has been asked in a similar way in the past but I'm just curious.

    If I made a script and made it run every midnight to check if my memory usage was higher than let's say, 80... would it be a bad idea to make the script automatically run sync; echo 1 > /proc/sys/vm/drop_caches? I often get into an issue where my RAM usage gets to 99% because of this and I'm just getting a little bit worried.

    Thanks in advance.

    • Admin
      Admin over 9 years
      possible duplicate of Why drop caches in Linux?
    • Sreeraj
      Sreeraj over 9 years
      How do you check the memory usage and free memory?
    • user3650841
      user3650841 over 9 years
      $ free | grep Mem | awk '{print $3/$2 * 100.0}'
    • David Schwartz
      David Schwartz over 9 years
      Are you seriously asking how to get your computer to waste more memory rather than using it efficiently?