Purge Memory

Purge MemoryLinux does a good job when it comes to memory allocation. If memory isn’t being used or hasn’t been used for awhile it gets put into a cache where it can readily pulled. At times though this cache can become pretty big (especially for a program that has a memory leak). If a good number of programs are being used or if memory is limited then Linux will begin using hard disk swap which can really bog down performance. In these instances, it may help to purge the memory.

Note: This tip is entirely safe but sed authour in not accountable if computer sees Pigs on a Wing.

In the terminal type free -m to see memory usage. Now flush the filesystem buffers and drop extra caches.

sudo sync
sudo echo 3 | sudo tee /proc/sys/vm/drop_caches

Look once more and memory usage should be improved. Freeing memory is most effective by shutting down whatever programs can be. To be really effective shutdown X server first.

Original Tip: Howto: Clear filesystem memory cache 

About Gen2ly

<3's linux

8 thoughts on “Purge Memory

  1. Vadim P. says:

    Sweet, thanks.

  2. [...] karena link yang diberikan google di awal pencarian belum banyak yang terjelajahi. Ternyata ada cara lain yang menurut saya “lebih elegan”. Saya anggap begitu karena tidak harus menunggu agak [...]

  3. Kenji says:

    Excellent! =)

  4. überRegenbogen says:

    This is considerably more complex that it needs to be (I dare say that you’re a tad sudo happy. ;P)

    ‘sync’ normally shouldn’t require root privileges.
    ‘echo’ really doesn’t (and is internal in most shells).
    All ‘tee’ does it show you the 3—which doesn’t accomplish much.

    So the crux of this is: “echo 3 >/proc/sys/vm/drop_caches”

    Which doesn’t have the affect that i’d hoped (i was looking for something to discourage swap use—à la “swapoff -a ; swapon -a”, but less aggressive); but it may be helpful, nonetheless. Thanks! ☺

  5. überRegenbogen says:

    Oh i suppose the purpose of tee was for the file writing to happen during sudo (which i rarely use). So, for the sudo fans:

    sudo sh -c ‘echo 3 >/proc/sys/vm/drop_caches’

    or

    echo 3 | sudo tee /proc/sys/vm/drop_caches

  6. Joydeep says:

    Thanks a lot for this help. It works just fine.

  7. Thanks. Just what I was looking for.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s