Category: CommunityWhere Did My RAM Go?

Share this post...Tweet about this on TwitterShare on Google+0Share on Facebook0
Where did my RAM go?

Photo Credits: ArtBrom

For novice Linux system administrators who don’t have extensive experience running their site from a Linux box, one of the most commonly asked questions is: “Why is Linux using all my RAM?”.

Naturally, server admins want to get the biggest bang for their buck with their server, so they are concerned that its resources, particularly its memory, are being used efficiently. They find out about the “free” command, run it, and are upset to discover that they have almost no free RAM: it’s all being gobbled up by the system.


Photo Credits: Bogdan

In fact, this is a confusion resulting from a difference in the way that operating systems report their available and used memory. Windows users are used to seeing plenty of free memory reported by that operating system, and they apply the same concepts to Linux. However, Linux reports its memory usage somewhat differently which can lead to unnecessary concern on the part of sysadmins that don’t have a grasp of Unix memory management.

Why Does “free” Show No Free RAM?

The first thing to understand is that truly free memory is a wasted resource. Why would you want RAM sitting there doing nothing most of the time if there is something useful it could be doing?

In this case, the “something useful” is disk caching. The Linux kernel loads and keeps data in memory that it thinks it’s going to need fast access to. It’s much quicker to have frequently used data already waiting in memory than to pull it off the disk repeatedly. Linux loads up the free memory with caches and buffers; doing so considerably speeds up the system.

The confusion arises because different operating systems define “free” differently. For Linux, free means: “not being used for applications or caching”, whereas in Microsoft Windows it means: “not being used for applications”.

But Doesn’t That Mean Less Memory Is Available For My Applications?

No. The memory being used for disk caching is always available immediately for use by applications. If applications need memory that is being used for disk caching, the kernel reallocates that memory to the application. There is no downside to using disk caching: it makes the system run more quickly and it doesn’t take memory away from applications.

If you want to check this out, you can use the “free” command again, but focus on the line that begins “+/- buffers/cache”, which is the equivalent of the Windows way of displaying free memory i.e. memory that is not being used for application but is being used for caching. This is the memory that’s actually free for your applications to use should they need it.

What other tips do you have for folks new to Linux server administration? Any resources you found particularly helpful?

LinuxRAMSysAdmin Tools
Jul 9, 2013, 10:43 amBy: InterWorx (3) Comments
  1. Bogdan: You may want to include a more better image like: (remove the image afterwards please from this comment) where you see the buffered/cached memory, this will most definitely have a better view when explaining. Overall, its a good tip!
    July 17, 2013 at 3:43 pm
    • interworx: Thanks Captain Bogdan. We included your link and gave you credit. :D
      July 22, 2013 at 1:57 pm
      • Bogdan: Thanks, cheers! :)
        July 26, 2013 at 2:41 pm

Leave a Reply
Surround code blocks with <pre>code</pre>

Your email address will not be published.


Sign up to receive periodic InterWorx news, updates and promos!

New Comments

Current Poll

  • This field is for validation purposes and should be left unchanged.