Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 07-15-2010, 06:56 AM   #1
Registered: May 2008
Location: India
Distribution: Ubuntu 10.04, CentOS
Posts: 179

Rep: Reputation: 27
Question memory calculation

Hi All,

I want to calculate the total amount of memory used by the system,
Someone please confirm if the below formula is correct.
((memUsed-mebBuffers-memCached)*100)/memUsed => totalMemoryUsed%
free -o
             total       used       free     shared    buffers     cached
Mem:       8167004    8115292      51712          0      87680    1444676
Swap:      8388584    3252996    5135588

((8115292-87680-1444676)*100/8115292) => 81%
As per the above calculation 81% of memory is used.
Is this correct? and if so
Am I running out of memory?
what is the limit in % that I should maintain for a better performance?
Old 07-15-2010, 07:01 AM   #2
LQ Guru
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190
A used% value for memory is not very meaningful. It may not give you a good measure of whether you are "running out of memory".

In any case, your formula should be dividing by total, rather than by memUsed. That doesn't change the result much in your case, but under other conditions it might be a big difference.

((8115292-87680-1444676)*100/8167004) => 81%
By "running out of memory" I expect you mean something like "the system would run a lot faster if it had more memory". That is probably true for your system, but the info you posted doesn't prove it.

Since you have enough of swap space, your system isn't "running out of memory" in a literal sense. Almost all of your 5135588 KiB of free swap space plus a significant part of your 1444676 KiB of cache would need to be used by "anonymous" memory before you would literally run out of memory. That is likely more than double your current use level of anonymous memory.

Originally Posted by mario.almeida View Post
what is the limit in % that I should maintain for a better performance?
There is no meaningful answer to that question. The fraction of ram use in various categories does not translate directly into performance. What matters for performance is how much time the system is spending moving pages around, between the address spaces of processes and the cache and more importantly between the cache and the disk.

Your high use of swap space might indicate a lot of active anonymous pages have been pushed out to swap, meaning lack of memory is making your system much slower. But it equally well might mean you have a bunch of idle services running that own a lot of anonymous memory that they aren't trying to use, so that has properly been swapped out.

Your high level of memory use by processes as compared to cache might mean that code pages (and other file mappings) aged out of each process address space are quickly dropped from the cache for lack of space, so they must be frequently read back from the original files (.so files etc.) as they are faulted back into process address spaces (again meaning lack of memory is making the system slow). But it equally well might mean the use of file mappings by your processes is either small (most memory use anonymous) or stable, such that few pages age out of the process address space and the cache size is plenty for the use of cache.

Last edited by johnsfine; 07-15-2010 at 07:20 AM.
Old 07-15-2010, 07:18 AM   #3
Registered: Jul 2003
Posts: 242

Rep: Reputation: 26
hard to tell... I never use the free command as it doesn't tell the whole picture. For example how much slab is used? How much memory is mapped? maybe those numbers are included in others, but I'll let others help. The ONE thing that should be ignored is 'cache' as that is memory for caching files. The more files you open and read the more cache is used. However if the system needs the memory for something else, it just gets rid of older pages.

on my system:

[root@o185i193 plot]# free -o
total used free shared buffers cached
Mem: 4059252 2368812 1690440 0 194424 1909904
Swap: 1052216 0 1052216

[root@o185i193 plot]# collectl -sm --verbose -c1
#<---------------------------Physical Memory---------------------------><-----------Swap------------><-------Paging------>
# Total Used Free Buff Cached Slab Mapped Commit Inact Total Used Free In Out Fault MajFt In Out
3964M 2329M 1634M 194424K 1865M 114852K 162112K 421420K 1225M 1027M 0 1027M 0 0 19604 0 0 120

so you can see there is a lot more going on that free is telling you. In fact, if you look at /proc/meminfo you'll see even more.

Old 07-22-2010, 10:05 AM   #4
Registered: Aug 2008
Posts: 66

Rep: Reputation: 18
The “total” memory is the amount available after loading the kernel. Any memory being used for processes or disk buffering is listed as “used.” Memory that is currently unused is listed in the “free” column. Note that the total memory is equal to the sum of the “used” and “free” columns.

The memory indicated as “shared” is an indication of how much memory is common to more than one process. A program such as the shell typically has more than one instance running. The executable code is read-only and can be shared by all processes running the shell.

The “buffers” entry indicates how much of the memory in use is currently being used for disk buffering.

The “free” command also shows very clearly whether the swap space is enabled, and how much swapping is going on.

Source :

Last edited by vamsi_k; 07-22-2010 at 10:06 AM. Reason: more information


calculation, memory

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
date calculation satish.res Linux - Newbie 3 12-27-2009 05:31 AM
swap calculation mario.almeida Linux - General 5 08-03-2009 11:51 AM
TOP command: calculation of memory usage samiralmousawi Linux - Server 7 07-29-2008 03:16 PM
Calculation of signal levels? ikletti Linux - Wireless Networking 2 03-22-2005 04:46 AM
c math calculation alaios Programming 3 06-01-2004 01:46 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:16 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration