LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1838|回复: 13

如何优化Linux系统的内存使用?正在系统狂占内存

[复制链接]
发表于 2006-11-11 22:10:58 | 显示全部楼层 |阅读模式
这几天就在电脑里不断地安装软件,结果一开机内存已经使用500多M。
不知道为什么会这么夸张,由于对linux还不是很熟悉,所以想请教一下大家。
不知道大家平时开机时占用内存多少呢?
我的系统是fedora6,以下是我的系统的内存使用情况。
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.1  0.1   2028   648 ?        Ss   21:26   0:01 init [5]                                             
root         2  0.0  0.0      0     0 ?        S    21:26   0:00 [migration/0]
root         3  0.0  0.0      0     0 ?        SN   21:26   0:00 [ksoftirqd/0]
root         4  0.0  0.0      0     0 ?        S    21:26   0:00 [watchdog/0]
root         5  0.0  0.0      0     0 ?        S<   21:26   0:00 [events/0]
root         6  0.0  0.0      0     0 ?        S<   21:26   0:00 [khelper]
root         7  0.0  0.0      0     0 ?        S<   21:26   0:00 [kthread]
root        10  0.0  0.0      0     0 ?        S<   21:26   0:00 [kblockd/0]
root        11  0.0  0.0      0     0 ?        S<   21:26   0:00 [kacpid]
root        94  0.0  0.0      0     0 ?        S<   21:26   0:00 [cqueue/0]
root        97  0.0  0.0      0     0 ?        S<   21:26   0:00 [khubd]
root        99  0.0  0.0      0     0 ?        S<   21:26   0:00 [kseriod]
root       157  0.0  0.0      0     0 ?        S    21:26   0:00 [pdflush]
root       158  0.0  0.0      0     0 ?        S    21:26   0:00 [pdflush]
root       159  0.0  0.0      0     0 ?        S<   21:26   0:00 [kswapd0]
root       160  0.0  0.0      0     0 ?        S<   21:26   0:00 [aio/0]
root       313  0.0  0.0      0     0 ?        S<   21:26   0:00 [kpsmoused]
root       336  0.0  0.0      0     0 ?        S<   21:26   0:00 [ata/0]
root       337  0.0  0.0      0     0 ?        S<   21:26   0:00 [ata_aux]
root       340  0.0  0.0      0     0 ?        S<   21:26   0:00 [scsi_eh_0]
root       341  0.0  0.0      0     0 ?        S<   21:26   0:00 [scsi_eh_1]
root       346  0.0  0.0      0     0 ?        S<   21:26   0:00 [kmirrord]
root       353  0.0  0.0      0     0 ?        S<   21:26   0:00 [kjournald]
root       381  0.0  0.0      0     0 ?        S<   21:27   0:00 [kauditd]
root       418  0.0  0.1   2384   844 ?        S<s  21:27   0:00 /sbin/udevd -d
root       844  0.0  0.0      0     0 ?        S<   21:27   0:00 [kgameportd]
root      1358  0.0  0.0      0     0 ?        S<   21:27   0:00 [kmpathd/0]
root      1381  0.0  0.0      0     0 ?        S<   21:27   0:00 [kjournald]
root      1393  0.0  0.1   5372   812 ?        Ss   21:27   0:00 /sbin/mount.ntfs-3g /dev/hda5 /mnt/WinE -o rw,umask=000,nls=utf8
root      1781  0.0  0.0   2272   488 ?        Ss   21:27   0:00 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient-eth0.leases -pf /var/run/
root      1862  0.0  0.1   1792   704 ?        Ss   21:27   0:00 syslogd -m 0
root      1865  0.0  0.0   1640   396 ?        Ss   21:27   0:00 klogd -x
rpc       1898  0.0  0.1   1772   556 ?        Ss   21:27   0:00 portmap
root      1919  0.0  0.1   1884   808 ?        Ss   21:27   0:00 rpc.statd
root      1952  0.0  0.1   4928   556 ?        Ss   21:27   0:00 rpc.idmapd
dbus      1970  0.0  0.2   3268  1044 ?        Ss   21:27   0:00 dbus-daemon --system
root      1981  0.0  0.1   2440   932 ?        Ss   21:27   0:00 /usr/sbin/hcid
root      1993  0.0  0.0   1712   500 ?        Ss   21:27   0:00 /usr/sbin/sdpd
root      2005  0.0  0.0      0     0 ?        S<   21:27   0:00 [krfcommd]
root      2043  0.0  0.2  33180  1388 ?        Ssl  21:27   0:00 pcscd
root      2063  0.0  0.0   1880   456 ?        Ss   21:27   0:00 /usr/bin/hidd --server
root      2078  0.0  0.2   9036  1056 ?        Ssl  21:27   0:00 automount
root      2097  0.0  0.1   1640   528 ?        Ss   21:27   0:00 /usr/sbin/acpid
root      2108  0.0  0.0   5052   476 ?        Ss   21:27   0:00 ./hpiod
root      2113  0.0  0.9  14068  4796 ?        S    21:27   0:00 python ./hpssd.py
root      2125  0.0  0.4  10952  2172 ?        Ss   21:27   0:00 cupsd
root      2136  0.0  0.1   5172   916 ?        Ss   21:27   0:00 /usr/sbin/sshd
root      2156  0.0  0.3   8512  1652 ?        Ss   21:29   0:00 sendmail: accepting connections
smmsp     2164  0.0  0.2   7572  1452 ?        Ss   21:29   0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      2176  0.0  0.0   1864   360 ?        Ss   21:29   0:00 gpm -m /dev/input/mice -t exps2
root      2187  0.0  0.0   1784   448 ?        S    21:29   0:00 nasd -b -local
root      2198  0.0  0.2   6320  1088 ?        Ss   21:29   0:00 crond
xfs       2235  0.0  0.3   3868  1716 ?        Ss   21:29   0:00 xfs -droppriv -daemon
root      2256  0.0  0.0   2200   428 ?        Ss   21:29   0:00 /usr/sbin/atd
root      2280  0.0  2.0  25384 10704 ?        S    21:29   0:00 /usr/bin/python /usr/sbin/yum-updatesd
avahi     2292  0.0  0.2   2860  1420 ?        Ss   21:29   0:00 avahi-daemon: running [liyiwen.local]
avahi     2293  0.0  0.0   2860   316 ?        Ss   21:29   0:00 avahi-daemon: chroot helper process
68        2304  0.2  0.7   5864  3924 ?        Ss   21:29   0:02 hald
root      2305  0.0  0.2   3332  1104 ?        S    21:29   0:00 hald-runner
68        2311  0.0  0.1   2292   968 ?        S    21:29   0:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
68        2318  0.0  0.1   2292   972 ?        S    21:30   0:00 hald-addon-keyboard: listening on /dev/input/event0
root      2328  0.0  0.1   2244   784 ?        S    21:30   0:00 hald-addon-storage: polling /dev/hdc
root      2413  0.0  0.0   1948   468 ?        S    21:30   0:00 /usr/sbin/smartd -q never
root      2425  0.0  0.0   1628   440 tty1     Ss+  21:30   0:00 /sbin/mingetty tty1
root      2426  0.0  0.0   1628   440 tty2     Ss+  21:30   0:00 /sbin/mingetty tty2
root      2427  0.0  0.0   1624   436 tty3     Ss+  21:30   0:00 /sbin/mingetty tty3
root      2428  0.0  0.0   1624   436 tty4     Ss+  21:30   0:00 /sbin/mingetty tty4
root      2429  0.0  0.0   1628   464 tty5     Ss+  21:30   0:00 /sbin/mingetty tty5
root      2443  0.0  0.0   1624   436 tty6     Ss+  21:30   0:00 /sbin/mingetty tty6
root      2444  0.0  0.2   5588  1144 ?        Ss   21:30   0:00 /bin/sh /etc/X11/prefdm -nodaemon
root      2447  0.0  0.8  17840  4280 ?        S    21:30   0:00 /usr/sbin/gdm-binary -nodaemon
root      2519  0.0  0.5  17104  2804 ?        S    21:30   0:00 /usr/sbin/gdm-binary -nodaemon
root      2523  0.1  0.2  17840  1480 ?        S    21:30   0:00 /usr/sbin/gdm-binary -nodaemon
root      2524 10.0  3.0  22468 15456 tty7     Rs+  21:30   1:23 /usr/bin/Xorg :0 -br -audit 0 -auth /var/gdm/:0.Xauth -nolisten tcp vt7
root      2548  0.0  1.2  24180  6236 ?        Ss   21:31   0:00 /usr/bin/gnome-session
root      2574  0.0  0.0      0     0 ?        Z    21:31   0:00 [Xsession] <defunct>
root      2599  0.0  0.0   4284   492 ?        Ss   21:31   0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session /etc/X11/xinit/Xc
root      2602  0.0  0.2   3140  1276 ?        Ss   21:31   0:00 /bin/dbus-daemon --fork --print-pid 8 --print-address 6 --session
root      2603  0.0  0.1   2816   520 ?        S    21:31   0:00 /usr/bin/dbus-launch --exit-with-session /etc/X11/xinit/Xclients
root      2610  0.0  0.7   8860  4072 ?        S    21:31   0:00 /usr/libexec/gconfd-2 5
root      2613  0.0  0.1   2532   748 ?        S    21:31   0:00 /usr/bin/gnome-keyring-daemon
root      2615  0.0  1.6  34968  8268 ?        Sl   21:31   0:00 /usr/libexec/gnome-settings-daemon
root      2619  0.0  2.1  26020 11208 ?        Ss   21:31   0:00 /usr/lib/scim-1.0/scim-launcher -d -c simple -e all -f socket --no-stay
root      2634  0.0  1.2  36496  6232 ?        Ss   21:31   0:00 gnome-power-manager
root      2636  0.3  2.2  40708 11676 ?        Ss   21:31   0:02 metacity --sm-client-id=default1
root      2640  0.0  0.1   7216   544 ?        Ss   21:31   0:00 /usr/lib/scim-1.0/scim-helper-manager
root      2641  0.1  1.4  50680  7504 ?        Ssl  21:31   0:01 /usr/lib/scim-1.0/scim-panel-gtk --display :0.0 -c socket -d --no-stay
root      2643  0.1  0.2  14400  1404 ?        Ss   21:31   0:01 /usr/lib/scim-1.0/scim-launcher -d -c socket -e socket -f x11
root      2645  0.1  3.0  61676 15892 ?        Ss   21:31   0:01 gnome-panel --sm-client-id default2
root      2647  0.1  3.7  98952 19092 ?        Ss   21:31   0:01 nautilus --no-default-window --sm-client-id default3
root      2652  0.0  0.4  17468  2184 ?        Ss   21:31   0:00 gnome-screensaver
root      2654  0.0  0.5  39820  2764 ?        Ssl  21:31   0:00 /usr/libexec/bonobo-activation-server --ac-activate --ior-output-fd=16
root      2661  0.0  0.2   2524  1172 ?        S    21:31   0:00 /usr/libexec/gam_server
root      2663  0.0  0.6  12448  3276 ?        S    21:31   0:00 /usr/libexec/gnome-vfs-daemon
root      2667  0.2  2.3  59732 12332 ?        S    21:31   0:02 /usr/libexec/wnck-applet --oaf-activate-iid=OAFIID:GNOME_Wncklet_Factory --oa
root      2669  0.0  1.5  67412  7772 ?        S    21:31   0:00 /usr/libexec/trashapplet --oaf-activate-iid=OAFIID:GNOME_Panel_TrashApplet_Fa
root      2682  0.0  1.2  24200  6508 ?        S    21:31   0:00 /usr/libexec/notification-area-applet --oaf-activate-iid=OAFIID:GNOME_Notific
root      2684  0.0  2.2  49796 11624 ?        S    21:31   0:00 /usr/libexec/clock-applet --oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory
root      2686  0.1  2.5  59640 12872 ?        S    21:31   0:01 /usr/libexec/mixer_applet2 --oaf-activate-iid=OAFIID:GNOME_MixerApplet_Factor
root      2696  0.0  0.1   2440   832 ?        S    21:31   0:00 /usr/libexec/mapping-daemon
root      2698  0.0  1.6  45900  8312 ?        Ss   21:32   0:00 eggcups --sm-client-id default4
root      2700  0.0  0.9  15640  4672 ?        Ss   21:32   0:00 bluetooth-applet
root      2708  0.0  2.6  26220 13472 ?        Ss   21:32   0:00 /usr/bin/python -tt /usr/bin/puplet
root      2715  0.0  1.8  36692  9656 ?        Ss   21:32   0:00 nm-applet --sm-disable
root      2721  0.0  0.8  16208  4168 ?        Ss   21:32   0:00 pam-panel-icon --sm-client-id default0
root      2723  0.0  0.3  16348  2008 ?        Sl   21:32   0:00 ./escd --key_Inserted="/usr/bin/esc" --on_Signal="/usr/bin/esc"
root      2738  0.0  0.2   5544  1088 ?        S    21:32   0:00 /bin/sh /usr/lib/firefox-1.5.0.8/firefox
root      2758  0.0  0.2   5544  1096 ?        S    21:32   0:00 /bin/sh /usr/lib/firefox-1.5.0.8/run-mozilla.sh /usr/lib/firefox-1.5.0.8/fire
root      2763 13.0 10.9 202776 56136 ?        Rl   21:32   1:30 /usr/lib/firefox-1.5.0.8/firefox-bin
root      2767  0.0  2.6  28612 13660 ?        S    21:32   0:00 scim-bridge
root      2776  0.0  0.1   1808   628 ?        S    21:33   0:00 /sbin/pam_timestamp_check -d root
root      2782  0.3  5.3 124936 27560 ?        Sl   21:34   0:01 /usr/bin/python /usr/bin/bittorrent
root      2827  0.6  3.1  81456 16316 ?        Sl   21:40   0:01 gnome-terminal
root      2832  0.0  0.1   2444   692 ?        S    21:40   0:00 gnome-pty-helper
root      2833  0.0  0.2   5592  1404 pts/1    Ss   21:40   0:00 bash
root      2860  0.0  0.1   5328   936 pts/1    R+   21:44   0:00 ps aux
[root@liyiwen ~]# free
             total       used       free     shared    buffers     cached
Mem:        514208     508056       6152          0      37256     290956
-/+ buffers/cache:     179844     334364
Swap:      1048568          0    1048568
发表于 2006-11-11 22:37:59 | 显示全部楼层
你机器内存是多少?
你是不是把预读也算进去了?
回复 支持 反对

使用道具 举报

发表于 2006-11-11 22:39:36 | 显示全部楼层
LIN和WIN的管理机制不同,WIN是空着,要多少拿多少。LIN是全占着,再分配给进程。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-11-11 22:58:11 | 显示全部楼层
Post by finux
LIN和WIN的管理机制不同,WIN是空着,要多少拿多少。LIN是全占着,再分配给进程。

那用free显示的信息代表什么?
[root@liyiwen ~]# free
  total       used              free     shared    buffers     cached
Mem:        514208     487564      26644          0      41952     271508
-/+ buffers/cache:     174104     340104
Swap:      1048568          0    1048568

上面的信息不是说有514208K内存,使用了487564?
占着是什么意思?是不是说那487564K内存只是占着,并没有完全用到?
那实际中用了多少内存?怎么查看?
我的机子的内存是512的,现在启动系统,和系统使用都觉得很慢。
回复 支持 反对

使用道具 举报

发表于 2006-11-12 16:43:49 | 显示全部楼层
首先你需要把不需要用到的service给去掉,这个有很多的讨论,你的process对于个人用户来说也确实多了一点。另外linux会用内存来作cache,所以,如果内存里面的process都是你必须的,你就不用担心了。linux比windows的内存利用效率高!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-11-12 20:02:39 | 显示全部楼层
那我自己先了解一下service,各位谢了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-11-12 21:21:35 | 显示全部楼层
还是请各位帮帮忙,我居然没找到对service的相关讨论。
我 在“服务配置里”发现如下服务都打上勾的。
acpid
anacron
apmd
atd
automount
avahi-daemon
Bluetooth
cpuspeed
crond
cups
firstboot
gpm
haldaemon
hidd
HPLIP
kudzu
mcstarts
mdmonitor
messagebus
nasd
netfs
network
nflock
pcscd
portmap
readahead_early
readahead_later
restorecond
RPCSECD
rpc.idmapd
smartd
sshd
syslogd
yum-updatesd
请问哪个服务是系统运行所必需的,哪个服务是可以停止而加快系统运行?
当然必需是相对的,我指的是对于一个只是作为个人使用,侧重考虑性能。
请各位热心的朋友帮帮忙
回复 支持 反对

使用道具 举报

发表于 2006-11-12 22:27:32 | 显示全部楼层
我是初学者
Bluetooth可以不要
yum-updatesd,如果你不知道yum是啥,也可以不要
回复 支持 反对

使用道具 举报

发表于 2006-11-12 22:29:58 | 显示全部楼层
我用的是LFS,我的机器上只装了也只开了automount, gpm, syslogd,不知道你的机器上如何,呵呵
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-11-12 23:53:58 | 显示全部楼层
我列出的服务差不多都在运行的~
yum 我是经常用的,因为对我来说,用它安装软件相当简便
其他除了network我基本上都不认识-_-
虽然每个服务都可以查到相关的介绍,但如果有熟悉的人概括性的介绍一下,
分享一下经验,对新手来说是相当宝贵的。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表