Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-04-2011, 08:43 AM   #1
LQ Newbie
Registered: Jun 2011
Posts: 19

Rep: Reputation: Disabled
How to find actual used memory

Hello all,
Im trying to find a way in redhat to see if there is a command that could tell me the actual used memory by the system.
For example when i do the free command, i want to see the Used minus cached value.
Is there a way linux can report the true used memory and not the cached/buffer etc?
if there is not specific command for that, can someone tell me a bash script that could calculate used-cached ?

Old 07-04-2011, 09:09 AM   #2
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,813

Rep: Reputation: 749Reputation: 749Reputation: 749Reputation: 749Reputation: 749Reputation: 749Reputation: 749
Linux, like any modern OS, is a virtual memory system, so Used can be either larger or smaller than physical memory. Why do you think there is some simple relationship between Used, Cached and Free? These commands get their values from /proc/meminfo, you can do any calculation that you want based on those.

Edit: on second thought, I think free gives you exactly what you want:
 free -m
             total       used       free     shared    buffers     cached
Mem:           503        494          8          0         40        225
-/+ buffers/cache:        227        275
Swap:          502          0        501
of 503 MB on this system, 227 is "used" and 275 is either free or available for use but currently occupied.

Last edited by smallpond; 07-04-2011 at 10:38 AM. Reason: Additional info
Old 07-04-2011, 10:51 AM   #3
LQ Newbie
Registered: Jun 2011
Posts: 19

Original Poster
Rep: Reputation: Disabled
doesnt seem to be the case here. We have some servers running rhel 5.4. On all of them we have 48gb ram.
The free command shows:

total used free shared buffers cached
Mem: 49451512 49011308 440204 0 457952 34333736
-/+ buffers/cache: 14219620 35231892
Swap: 20972848 119852 20852996

free command shows that only 440204 is available, which is definitely not the case, otherwise the software the servers are running, would have crashed.
So im just trying to simply get a better idea(not exact) of the actual memory used. Thus i thought of maybe doing used - cached.
Old 07-04-2011, 10:56 AM   #4
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,144
Blog Entries: 2

Rep: Reputation: 4846Reputation: 4846Reputation: 4846Reputation: 4846Reputation: 4846Reputation: 4846Reputation: 4846Reputation: 4846Reputation: 4846Reputation: 4846Reputation: 4846
To get a better understanding of the output of free you should read this article, it explains exactly what you want to know.
Old 07-04-2011, 11:21 AM   #5
LQ Newbie
Registered: Jun 2011
Posts: 19

Original Poster
Rep: Reputation: Disabled
Thanks Tobi,
That article helps.

can someone point to me a grep command that can just pull that number from the free -m output.

i can get the output from the free command by using command free -m |awk -F " " '{print $4}'


how can i get just the 3rd row(34369) from this output? thanks

never mind, i think i got it: free -m |awk -F " " '{print $4}' |sed -n 3,3p

Last edited by alirz; 07-04-2011 at 11:24 AM.
Old 07-04-2011, 11:25 AM   #6
LQ Newbie
Registered: Jul 2011
Posts: 3

Rep: Reputation: Disabled
free -lm
total used free shared buffers cached
Mem: 3032 1307 1725 0 120 631
Low: 858 199 658
High: 2174 1108 1066
-/+ buffers/cache: 555 2477
Swap: 2167 0 2167

or maybe you need something like

vmstat -S m
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
1 0 0 1794 126 666 0 0 29 83 1186 1423 26 3 69 2

the output is on Megabytes


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
[SOLVED] Allocated memory is less in file system compared to the actual allocation vijaysince89 Linux - Virtualization and Cloud 5 11-04-2010 03:39 AM
Finding linux actual memory usage wmasry Linux - General 1 12-16-2009 08:09 AM
How can I find the actual Virtual -> Physical Memory Map Pages? VorlonInfoTech Linux - General 0 12-23-2008 09:17 AM
Linux shows less memory than the actual installed jomy Linux - General 17 07-02-2008 09:46 AM
get the actual hardware memory address of kernel oops edman007 Linux - General 0 02-24-2005 10:26 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:19 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