?
Solved

how to calculate total memory used in freebsd ?

Posted on 2008-10-12
8
Medium Priority
?
1,067 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 1000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

777 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