Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more


how to calculate total memory used in freebsd ?

Posted on 2008-10-12
Medium Priority
Last Modified: 2013-11-22
I am using these two command in freebsd box.

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

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

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 ?
Question by:beer9
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
LVL 62

Accepted Solution

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?

Author Comment

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 ?
LVL 62

Expert Comment

ID: 22726779
There are shared libraries and SHM segments that count multiple times if you run daemonized servers and/or databases.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

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..
LVL 62

Expert Comment

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.

Author Comment

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 ?

Author Closing Comment

ID: 31505433
LVL 62

Expert Comment

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

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…
Suggested Courses

647 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