How to clear memory buffer/cache, and how to clear swap memory

Forum Forums General Tips and Tricks How to clear memory buffer/cache, and how to clear swap memory

  • This topic has 1 reply, 2 voices, and was last updated Jan 24-1:51 am by Anonymous.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #47494
    Member
    andyprough

      Here are my notes on how to clear most of the memory buffer/cache and how to clear swap memory (run these commands as root):
      Clear page memory –
      sync; echo 1 > /proc/sys/vm/drop_caches

      Not recommended – can cause data loss – clear dentries (data structure that represents a directory) and inodes (data structure that represents a file) –
      sync; echo 2 > /proc/sys/vm/drop_caches

      Clear swap –
      swapoff -a && swapon -a

      Anyone have any thoughts? I’ve used commands #1 and #3 for a couple years, haven’t had any trouble, and occasionally use command #2. I’d like to know if anyone has a thought on how these commands could be improved, or if you feel they are incorrect or if they are simply a waste of time for any reason.

      #50584
      Anonymous
        Helpful
        Up
        0
        ::

        We haven’t discussed this for a while, maybe not since back in the “antiX oldforums archives” days.
        When I saw this topic title today, “linux ate my RAM” popped into my head.
        I checked, and by golly ~~ https://www.linuxatemyram.com/ ~~ the site I remember from BackWhen is still available.

        The RAM modules are continually (re)energized, regardless “full” or “empty”, eh.
        Toward power management BestPractices, and with an eye toward reducing POH (power-on hours), I configure any spinning drives (man hdparm) to quickly power down between uses. So from my perspective, “drop caches” would be counterproductive… unless while managing a machine with < 1GB (?) RAM.

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.