Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I was wondering if there is a command that frees up cached RAM

I often have 1GB cached RAM when I only have 1.7GB of RAM, and when I start an application like Minecraft (uses a lot of RAM) and the computer starts using 500MB of swap instead and becomes very very slow.

That's why I want to free up RAM before I start any games/apps.

share|improve this question
    
can you clarify why you're asking this? The linux kernel uses advanced caching strategies, and should automatically swap things out of RAM when needed. –  ImaginaryRobots Nov 11 '11 at 17:22

2 Answers 2

up vote 6 down vote accepted

Cached RAM? Not really, but that's RAM managed by the kernel to cache disk reads, so it shouldn't impact your system's performance, in fact it should help it. You can change the way the kernel caches things, but I don't think you can explicitly free RAM that's currently used as a page cache. Generally newer kernels try to use as much free RAM as possible as a cache and free and re-allocate it as you start new processes, so you're generally going to see quite a lot cached. Why do you want to free it?

share|improve this answer

To free pagecache:

echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

echo 3 > /proc/sys/vm/drop_caches

use with root permissions

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.