4

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.

1
  • 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. Nov 11, 2011 at 17:22

3 Answers 3

13

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

10

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?

1
  • Apps use RAM, not important how it got used, but in heavier app load, you WILL run out of RAM and your PC WILL freeze it's a common misconception that Linux is all that great with RAM it isn't.
    – jave.web
    Aug 8, 2020 at 15:14
0

I have had issues with say my laptop with slowdowns and swap memory being used up at a high percentage, now there is a way to do so in the terminal, and even as a cron-job, i have done the latter for every 15 mins, and it does help, with still an occasional slow down depending on usage of my laptop. Depending on how you would like to do it, look at this link here Clean or disable the memory cache

and as I have said I have set it as a cron-job, so if you want to do it that way look for the solution that says "Make it a cron-job"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .