As @khedron says, you can see this info in Activity Monitor.
If you want it on the command line, here is a Python script that I wrote (or perhaps modified from someone else's, I can't remember, it's quite old now) to show you the Wired, Active, Inactive and Free memory amounts:
#!/usr/bin/python
import subprocess
import re
# Get process info
ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0].decode()
vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0].decode()
# Iterate processes
processLines = ps.split('\n')
sep = re.compile('[\s]+')
rssTotal = 0 # kB
for row in range(1,len(processLines)):
rowText = processLines[row].strip()
rowElements = sep.split(rowText)
try:
rss = float(rowElements[0]) * 1024
except:
rss = 0 # ignore...
rssTotal += rss
# Process vm_stat
vmLines = vm.split('\n')
sep = re.compile(':[\s]+')
vmStats = {}
for row in range(1,len(vmLines)-2):
rowText = vmLines[row].strip()
rowElements = sep.split(rowText)
vmStats[(rowElements[0])] = int(rowElements[1].strip('\.')) * 4096
print 'Wired Memory:\t\t%d MB' % ( vmStats["Pages wired down"]/1024/1024 )
print('Active Memory:\t\t%d MB' % ( vmStats["Pages active"]/1024/1024 ))
print('Inactive Memory:\t%d MB' % ( vmStats["Pages inactive"]/1024/1024 ))
print('Free Memory:\t\t%d MB' % ( vmStats["Pages free"]/1024/1024 ))
print('Real Mem Total (ps):\t%.3f MB' % ( rssTotal/1024/1024 ))
As you can see, you can just call vm_stat
from the command line, though it counts in 4kB pages, hence the script to convert to MB.
The script also counts up the "real memory" usage of all running processes for comparison (this won't match any specific value(s) from overall memory stats, because memory is a complex beast).
Here's an example of the output of the script on my system:
[user@host:~] % memReport.py
Wired Memory: 1381 MB
Active Memory: 3053 MB
Inactive Memory: 727 MB
Free Memory: 1619 MB
Real Mem Total (ps): 3402.828 MB
(very slightly adjusted to match the tab sizing on StackExchange ;)
I have 10.6.7 and your
ps -u `whoami` -o pid,rss,command
producing
PID RSS COMMAND
180 696 /sbin/launchd
185 19108 /System/Library/CoreServices/SystemUIServer.app/Contents/MacOS/SystemUIServer
189 32 /usr/sbin/pboard
.... etc ....
so, the problem is in your system. So, what return this:
ls -l /bin/ps
should this
-r-sr-xr-x 1 root wheel 134816 12 okt 2010 /bin/ps
if your ps has other permissions, repair with:
sudo chown root /bin/ps
sudo chgrp wheel /bin/ps
sudo chmod 4555 /bin/ps
Best Answer
The problem is with clearing inactive memory in the first place, regardless of which command is used to do it.
Indeed, using purge is "not a good idea" but the problem is due to what the end result of the command is rather than how the command does it or other specific problem due to the command.
Running purge attempts to clear inactive memory. An 'alternative' command would not be any better than running purge, providing it does the same thing.
This excellent answer explains the reasoning behind inactive memory in more detail: