Difference between revisions of "Memory"

From Hackepedia
Jump to navigationJump to search
 
Line 21: Line 21:
  
 
rss  =    resident set size
 
rss  =    resident set size
 +
 +
Lookup "KEYWORDS" in the ps [[Manual]] for a list of keys you can display.
  
  

Revision as of 09:17, 27 October 2005

Debugging memory hogs in BSD

To discover which process is using the most memory percentage wise:

# ps aumx | head
USER    PID %CPU %MEM   VSZ  RSS  TT  STAT STARTED      TIME COMMAND
frankk 64873  0.0  7.9 71352 61644  ??  S    11:17PM  20:07.78 /usr/X11R6/lib/firefox/firefox-bin
frankk   607  0.0  7.7 74080 59832  ??  S     4:25PM   6:18.70 /usr/X11R6/lib/thunderbird/thunderbird-bin
frankk   583  0.0  7.0 64728 54568  ??  I     4:25PM  17:46.62 /usr/X11R6/lib/firefox/firefox-bin
root    561  0.8  3.0 152640 23116  v0  R     4:25PM  10:37.38 X :0 -nolisten tcp (Xorg)
frankk   869  0.0  3.7 34332 29036  ??  S     6:10PM   6:13.38 gaim
frankk   611  0.0  1.6 16476 12560  ??  S     4:28PM   1:39.09 xchat
root    678  0.0  0.5  5604 4000  ??  S     4:54PM   0:05.35 xterm (xterm-static)
root    644  0.0  0.5  5512 3916  ??  S     4:35PM   0:14.46 xterm (xterm-static)
root    392  0.0  0.3  3460 2332  ??  Ss    4:24PM   0:01.97 sendmail: accepting connections (sendmail)

Two other columns worth noting:

vsz = virtual size in Kbytes (alias vsize)

rss = resident set size

Lookup "KEYWORDS" in the ps Manual for a list of keys you can display.


Also don't forget to ensure there is always enough room in your swap:

# swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/ad0s1b        105288    68596    36692    65%

otherwise you'll start getting errors to syslog, running applications will be killed, and it will create a general mess of things:

Oct 27 09:51:38 mail swap_pager_getswapspace(9): failed
Oct 27 09:51:38 mail swap_pager_getswapspace(5): failed
Oct 27 09:51:38 mail swap_pager_getswapspace(16): failed
Oct 27 09:51:40 mail pid 95400 (perl5.8.7), uid 125, was killed: out of swap space


If you are running out of swapspace frequently, you can add a swapfile very easily on FreeBSD.