Solved

how to calculate total memory used in freebsd ?

Posted on 2008-10-12
8
1,062 Views
Last Modified: 2013-11-22
I am using these two command in freebsd box.

ps aux | awk '{memory +=$4}; END {print memory }'
5134.9

ps aux | awk '{memory +=$6}; END {print memory }'
246991968


whereas total physical memory is
sysctl -a | grep -i hw.physmem
hw.physmem: 4289929216

What is the difference between the output of %Mem and RSS of 'ps' command ?
0
Comment
Question by:beer9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 62

Accepted Solution

by:
gheist earned 250 total points
ID: 22703675
pmem - percent of RAM taken by program (exluding swapped ans shared)
rss - same in kilobytes.

Actually "man ps" manual page lists keywords.

4GB physical memory is unaddressable by 32bit app fully. Some address space is eaten by shared mem, and some by kernel.

Is there any perceived problem you are solving or just plain curiosity?
0
 

Author Comment

by:beer9
ID: 22720102
if 32bit machine can't use more than 4GB, then how come "ps aux | awk '{memory +=$4}; END {print memory }'" gives around 5GB(5134.9) size ? pmem should be maximum of 100, shouldn't it ?
0
 
LVL 62

Expert Comment

by:gheist
ID: 22726779
There are shared libraries and SHM segments that count multiple times if you run daemonized servers and/or databases.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:beer9
ID: 22728576
yeah.. I am running above in mysql server.. which have around 900 established connection. So I want to find how much memory mysql processes are using..
0
 
LVL 62

Expert Comment

by:gheist
ID: 22729223
opesource databases are notoriously intrackable in regard of memory usage.
you should take sum of virtual memory sizes, and retract shared memory size from each process using shared memory (as seen by ipcs -m)
Then dynamic loader comes around - it loads one instance of shared library ans shares between multiple processes.
0
 

Author Comment

by:beer9
ID: 22787070
on more info I need, how can I identify whether particular process is a shared libraries or SHM segments, I will count those process only once to get the accurate result.

P.S: what is SHM ?
0
 

Author Closing Comment

by:beer9
ID: 31505433
Excellent!
0
 
LVL 62

Expert Comment

by:gheist
ID: 23196994
You can get full path to executable from ps, then use ldd command to see which modules can be loaded.

SHM - SysV shared memory
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question