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.

The output of free -m:

                         total      used       free       shared    buffers     cached
Mem:                      595        482        112          0         63        324
-/+ buffers/cache:                    93        501
swap:                       0          0          0

Which value of free memory is correct 482 or 93?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

You have 112 MB of completely free memory, BUT the 501 mb you see is without 'cached' memory. This means that the OS has put some stuff in your memory to be quicker. It calls this "used" (therefore your 'free' number is only 112), but it is actually available for you if you need it.

This is a good thing, because unused memory is useless memory. The cached memory can be cleared if needed. The old "I need to clean up memory" stuff people used to do for windows 95 isn't needed here: it's all fine and happy :)

The number you are looking for is 501 free (in megabytes because of -m).

see for reference these pages:

http://www.linuxatemyram.com/
http://www.itworld.com/it-managementstrategy/280695/making-sense-memory-usage-linux

share|improve this answer
    
no. The layout was strange. I tried to fix it, but waiting for a mod to come by to acknowledge it. It's the 3rd number on the first line you need for "really free" memory. But you want to look at the 501 number –  Nanne Nov 30 '12 at 9:49
    
Bascially: "just look at the second line, the one with the buffers/cache". –  Nanne Nov 30 '12 at 9:55
add comment

Interpretting output of free:
The first line of the free output lists:

  • total Your total, physical (assuming no virtualization) memory
  • used How much of that is currently used (by anything)
  • free How much of that is completely free (not used at all)
  • shared (never anything there, ignore that column)
  • buffers Memory used by kernel buffers
  • cached Memory used for cache

The last two items, cache and buffers, is memory that is not allocated to specific user processes. It is memory reserved by the kernel to improve performance overall, but is not "application" memory. These areas will grow or shrink depending on kernel policies with respect to caching, memory pressure, application I/O patterns, etc.

Since these two columns are not user-allocated memory, and the zones can shrink (practically to zero) if user allocations require it, they are in a sense "free" - there's RAM there that can be freed up by the kernel if your apps actively need it.

That's what the second line tells you. It removes the buffer and cache memory from the used column (that's what the - means), and adds (+) them to the free column. (Rounding issue will happen.)

(The last line shows the state of your swap space.)

Courtesy: http://unix.stackexchange.com/a/33549/14497

So, in your case 112MB is the completely free memory, and if you take into consideration the memory used for caching, which can be allocated to the user applications, if needed; then 501 MB is the actual maximum memory available for use.

share|improve this answer
    
A person looking for a readout of memory is never interested (or almost never) in how much memory is completely free, but how much is free to use. the cached memory is 'in use' but is also free to use, so you should look at that. –  Nanne Nov 30 '12 at 9:51
    
I'm not really sure why you say that? It seems to imply that someone would deliberatly remove cache (which is indeed a bad thing)? The point is that loading acuall stuff (like a program you want to use) into that memory is actually an option. You want that 112 number to be as low as possible, but that would mean in your theory that you can't open any programs. Not the goal i'd say. Also: that cache isn't just disc-cache, it's also system cache and the likes –  Nanne Nov 30 '12 at 10:09
    
@Nanne, Ok. I agree man. Thanks for the correction. I have updated my answer to reflect the same. –  saji89 Nov 30 '12 at 10:20
    
##### THANK YOU ALL @ Nanne @devav2 @ saji89 FOR SHARING KNOWLEDGE - YOU ARE AWESOME ##### –  amoooc Dec 6 '12 at 17:30
    
@amoooc, You're welcome. –  saji89 Dec 7 '12 at 4:39
add comment

free command shows the information about unused and used memory and swap space.

Below is the explanation provided by http://www.linfo.org/free.html

The first row, labeled Mem, displays physical memory utilization, including the amount of memory allocated to buffers and caches. A buffer, also called buffer memory, is usually defined as a portion of memory that is set aside as a temporary holding place for data that is being sent to or received from an external device, such as a HDD, keyboard, printer or network.

The second line of data, which begins with -/+ buffers/cache, shows the amount of physical memory currently devoted to system buffer cache. This is particularly meaningful with regard to application programs, as all data accessed from files on the system that are performed through the use of read() and write() system calls1 pass through this cache. This cache can greatly speed up access to data by reducing or eliminating the need to read from or write to the HDD or other disk.

The third row, which begins with Swap, shows the total swap space as well as how much of it is currently in use and how much is still available.

Lets analyse the your system's memory usage

You have used free command with '-m' option, which is used to display the result in megabytes

-m, --mega
              Display the amount of memory in megabytes.

Total memory is 595(Used+free)

Used: 482 Free: 112

482MB out of 595MB is used by your system, in which only 93MB is used by active programs and remaining 324MB are in cache

So when you run any program in future, say which requires more 120MB. All 112MB(currently free) will be given and remaining 8MB will be taken from the non-active program buffer/cache.

Edit: Found this link, which provides good explanation.

share|improve this answer
    
I don't think this is correct. If you discard cache you have 93mb used so you have 501 left. –  Nanne Nov 30 '12 at 9:54
    
Why do you think it is not correct. Free memory on OP system is 112MB + 324MB(which is cached). So when a new program starts it will use 112MB first and then the cache. –  devav2 Nov 30 '12 at 10:15
    
basically, because 595-93=501 and(give or take 1mb for rounding), and it kinda reads as if 112 is the number you think the op is looking for. –  Nanne Nov 30 '12 at 11:15
    
501 is correct and that is what I am trying to explain. Out of 595, 482 is used. In which only 93 is the active memory used by programs. So 112 is the free available + if needed more, the memory can be taken from the cache, which was previously used and currently not active. –  devav2 Nov 30 '12 at 11:32
    
ok, agree then :) –  Nanne Nov 30 '12 at 11:53
add comment

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.