Solved

how to calculate total memory used in freebsd ?

Posted on 2008-10-12
8
1,054 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now