How to clear cached memory on ubuntu

By default the Linux OS has a very efficient memory management process that should be freeing any cached memory on the machine that it is being run on. However when it comes to Cached memory the Linux OS may at times decide that the Cached memory is being used and is needed which can lead to memory related issues and ultimately take your server of any potentially free memory. To overcome this you can force the Linux OS to free up and stored Cached memory.

If you want to clear cached memory on ubuntu run the following command from your terminal

sync; sudo echo 3 > /proc/sys/vm/drop_caches

If you want to run this command every one hour you can use crontab to run this

Thanks to john for this tip

Sponsored Link

Incoming search terms:

Related posts

8 thoughts on “How to clear cached memory on ubuntu

  1. sync; echo 3 | sudo tee /proc/sys/vm/drop_caches

    ;-)

    [Reply]

    Nick Reply:

    I knew that! LMAO Just testing ;-)

    [Reply]

    Nick Reply:

    Woh! It works! Why did I doubt it? :)

    Just saw the cache on my sys monitor disappear.

    Heh :) System doesn’t like that, it’s building it again :)

    Thanks for that. Lovely!

    [Reply]

    Nick Reply:

    Actually, on first glance I spotted the ‘>’ wondering why it feeding info into ‘/proc/sys/vm/drop_caches’.

    I need to question more maybe?

    [Reply]

    jp.fox Reply:

    In ” sudo echo 3 > /proc/sys/vm/drop_caches “, sudo is used to execute “echo 3″ but redirection is made with current user.

    “tee” is used to redirect input directly to a file, so “sudo tee” user root rights to do it

    [Reply]

    Punkd81 Reply:

    Works perfect!

    [Reply]

Leave a comment

Your email address will not be published. Required fields are marked *