LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-04-2011, 09:43 AM   #1
alirz
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 ?

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

Rep: Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703
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:
Code:
 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 11:38 AM. Reason: Additional info
 
Old 07-04-2011, 11:51 AM   #3
alirz
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, 11:56 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
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, 12:21 PM   #5
alirz
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}'

shared
418
34369
20364

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 12:24 PM.
 
Old 07-04-2011, 12:25 PM   #6
xtenex
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
 
  


Reply


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 04:39 AM
Finding linux actual memory usage wmasry Linux - General 1 12-16-2009 09:09 AM
How can I find the actual Virtual -> Physical Memory Map Pages? VorlonInfoTech Linux - General 0 12-23-2008 10:17 AM
Linux shows less memory than the actual installed jomy Linux - General 17 07-02-2008 10:46 AM
get the actual hardware memory address of kernel oops edman007 Linux - General 0 02-24-2005 11:26 PM


All times are GMT -5. The time now is 04:27 PM.

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