Skip to content

Instantly share code, notes, and snippets.

@michaelminter
Created April 25, 2014 18:43
Show Gist options
  • Save michaelminter/11299200 to your computer and use it in GitHub Desktop.
Save michaelminter/11299200 to your computer and use it in GitHub Desktop.
Free Memory on Linux

Very often I used to find that my Linux box(s), Fedora & Ubuntu both started reserving more RAM over a period of time since its boot. And the actual RAM left free was less.

I knew it was holding some caches for itself so that it could find the programs loading “quickly” and something like that.

The most common way to free up RAM is Rebooting! But I wanted to avoid it, so did a little “Googling” and I came up with an interesting solution – Tell linux to flush all the caches.

# Flush file system buffers by executing
sync;

# free page cache
echo 1 > /proc/sys/vm/drop_caches;

# free dentries and inodes
echo 2 > /proc/sys/vm/drop_caches

# free page cache, dentries and inodes
echo 3 > /proc/sys/vm/drop_caches

Proved working on: Redhat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment