1

的输出# top -o size

last pid: 61935;  load averages:  0.82,  0.44,  0.39                              up 10+13:28:42  16:49:43
152 processes: 2 running, 150 sleeping
CPU: 10.3% user,  0.0% nice,  1.8% system,  0.2% interrupt, 87.7% idle
Mem: 5180M Active, 14G Inact, 2962M Wired, 887M Cache, 2465M Buf, 83M Free
Swap: 512M Total, 26M Used, 486M Free, 5% Inuse

  PID USERNAME  THR PRI NICE   SIZE    RES STATE   C   TIME   WCPU COMMAND
 1471 mysql      62  44    0   763M   349M ucond   3 222:19 74.76% mysqld
 1171 root        4  44    0   645M   519M sbwait  0  20:56  3.86% tfs
41173 root        4  44    0   629M   516M sbwait  4  19:17  0.59% tfs
41350 root        4  44    0   585M   467M sbwait  7  15:17  0.10% tfs
36382 root        4  45    0   581M   401M sbwait  1 206:50  0.10% tfs
41157 root        4  44    0   551M   458M sbwait  5  16:23  0.98% tfs
36401 root        4  45    0   199M   108M uwait   2  17:50  0.00% tfs
36445 root        4  44    0   199M    98M uwait   4  20:11  0.00% tfs
36420 root        4  45    0   191M    98M uwait   4  19:57  0.00% tfs
 3491 root        9  45    0 79320K 41292K uwait   4  40:22  0.00% tfs_db
40690 root        1  44    0 29896K  4104K select  1   0:05  0.00% sshd
44636 root        1  44    0 29896K  3896K select  4   0:00  0.00% sshd
22224 root        1  44    0 29896K  3848K select  6   0:00  0.00% sshd
42956 root        1  44    0 29896K  3848K select  4   0:00  0.00% sshd
  909 bind       11  76    0 27308K 14396K kqread  1   0:00  0.00% named
 1586 root        1  44    0 26260K  3464K select  4   0:00  0.00% sshd
40590 root        4  45    0 23480K  7592K uwait   1   5:11  0.00% auth
 1472 root        1  44    0 22628K  8776K select  0   0:41  0.00% perl5.8.9
22229 root        1  44    0 20756K  2776K select  0   0:00  0.00% sftp-server
42960 root        1  44    0 20756K  2772K select  2   0:00  0.00% sftp-server
44638 root        1  44    0 10308K  2596K pause   2   0:00  0.00% csh
42958 root        1  47    0 10308K  1820K pause   3   0:00  0.00% csh
22227 root        1  48    0 10308K  1820K pause   0   0:00  0.00% csh
36443 root        1  57    0 10248K  1792K wait    0   0:00  0.00% bash
36418 root        1  51    0 10248K  1788K wait    2   0:00  0.00% bash
41171 root        1  63    0 10248K  1788K wait    0   0:00  0.00% bash
36399 root        1  50    0 10248K  1784K wait    2   0:00  0.00% bash
41155 root        1  56    0 10248K  1784K wait    0   0:00  0.00% bash
40588 root        1  76    0 10248K  1776K wait    6   0:00  0.00% bash
36380 root        1  50    0 10248K  1776K wait    2   0:00  0.00% bash
41348 root        1  54    0 10248K  1776K wait    0   0:00  0.00% bash
 1169 root        1  54    0 10248K  1772K wait    0   0:00  0.00% bash
 3485 root        1  76    0 10248K  1668K wait    4   0:00  0.00% bash
61934 root        1  44    0  9372K  2356K CPU4    4   0:00  0.00% top
 1185 mysql       1  76    0  8296K  1356K wait    3   0:00  0.00% sh
 1611 root        1  44    0  7976K  1372K nanslp  0   0:08  0.00% cron
  824 root        1  44    0  7048K  1328K select  0   0:03  0.00% syslogd
 1700 root        1  76    0  6916K  1052K ttyin   3   0:00  0.00% getty
 1703 root        1  76    0  6916K  1052K ttyin   2   0:00  0.00% getty
 1702 root        1  76    0  6916K  1052K ttyin   5   0:00  0.00% getty
 1706 root        1  76    0  6916K  1052K ttyin   0   0:00  0.00% getty
 1705 root        1  76    0  6916K  1052K ttyin   1   0:00  0.00% getty
 1701 root        1  76    0  6916K  1052K ttyin   6   0:00  0.00% getty
 1707 root        1  76    0  6916K  1052K ttyin   4   0:00  0.00% getty
 1704 root        1  76    0  6916K  1052K ttyin   7   0:00  0.00% getty
  490 root        1  44    0  3204K   556K select  1   0:00  0.00% devd

我的游戏服务器非常滞后,我注意到只有 83M 的可用内存。

这不仅仅是top因为我也尝试过使用其他应用程序:

# /usr/local/bin/freem
SYSTEM MEMORY INFORMATION:
mem_wire:        3104976896 (   2961MB) [ 12%] Wired: disabled for paging out
mem_active:  +   5440778240 (   5188MB) [ 21%] Active: recently referenced
mem_inactive:+  15324811264 (  14614MB) [ 61%] Inactive: recently not referenced
mem_cache:   +   1015689216 (    968MB) [  4%] Cached: almost avail. for allocation
mem_free:    +     86818816 (     82MB) [  0%] Free: fully available for allocation
mem_gap_vm:  +       946176 (      0MB) [  0%] Memory gap: UNKNOWN
-------------- ------------ ----------- ------
mem_all:     =  24974020608 (  23817MB) [100%] Total real memory managed
mem_gap_sys: +    772571136 (    736MB)        Memory gap: Kernel?!
-------------- ------------ -----------
mem_phys:    =  25746591744 (  24553MB)        Total real memory available
mem_gap_hw:  +     23212032 (     22MB)        Memory gap: Segment Mappings?!
-------------- ------------ -----------
mem_hw:      =  25769803776 (  24576MB)        Total real memory installed

SYSTEM MEMORY SUMMARY:
mem_used:        9342484480 (   8909MB) [ 36%] Logically used memory
mem_avail:   +  16427319296 (  15666MB) [ 63%] Logically available memory
-------------- ------------ ----------- ------
mem_total:   =  25769803776 (  24576MB) [100%] Logically total memory

如您所见,输出类似:

mem_free: + 86818816 ( 82MB) [ 0%] Free: fully available for allocation.

我的专用有 24GB 的 RAM,这对于我的游戏服务器来说已经足够了。

我怎样才能找出哪个进程正在消耗这么多的内存?

我正在使用 FreeBSD 8.2。

4

1 回答 1

2

根据 top 的输出,您只使用了 5% 的交换。这意味着,您的RAM并不短缺——无论是什么让您慢下来,都不是内存短缺。如果有的话,我会怀疑 mysqld ——它不仅很忙,当你拍摄快照时,它还在此之前积累了相当多的 CPU 时间。

也许,一两个新索引可以帮助一些频繁运行的查询?

于 2013-07-22T18:14:26.643 回答