我面临一个问题,其中 Xorg 开始消耗越来越多的内存,最终耗尽整个交换空间。如下图,Xorg的虚拟内存约为1.1GB。我的系统只运行一个 GTK 应用程序“main_app”,并且我没有 Gnome,我只安装了 IceWM。当这种情况发生时,系统会爬行,只有重新启动才能恢复。
top - 00:01:09 up 24 days, 6:51, 6 users, load average: 6.89, 3.63, 2.76
Tasks: 126 total, 1 running, 123 sleeping, 2 stopped, 0 zombie
Cpu(s): 1.0%us, 3.4%sy, 0.0%ni, 0.0%id, 95.6%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 505644k total, 442536k used, 63108k free, 1424k buffers
Swap: 2095096k total, 1246372k used, 848724k free, 16400k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1598 root 19 -1 1145m 39m 1308 S 0 8.0 375:06.84 Xorg
2293 root 20 0 100m 6876 3932 S 2 1.4 747:08.62 main_app
514 root 20 0 53460 324 140 S 0 0.1 70:38.16 net.agent
1998 root 20 0 53460 368 140 S 0 0.1 70:40.18 net.agent
23787 root 20 0 53460 9980 196 D 1 2.0 0:00.21 net.agent
23801 root 20 0 53460 9248 196 D 1 1.8 0:00.19 net.agent
1343 root 20 0 28472 804 564 S 0 0.2 0:03.88 rsyslogd
3179 root 20 0 23712 180 136 S 0 0.0 0:15.82 MSPAgent
如下所示,/proc/pid/smaps 显示 xorg 的堆拥有全部 1.1GB。
08231000-4da43000 rw-p 00000000 00:00 0 [heap]
Size: 1138760 kB
Rss: 35444 kB
Pss: 35444 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 1476 kB
Private_Dirty: 33968 kB
Referenced: 26436 kB
Swap: 1103276 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
我运行了 xrestop,但我发现“main_app”不是罪魁祸首。
xrestop - Display: :0.0
Monitoring 9 clients. XErrors: 0
Pixmaps: 1465K total, Other: 35K total, All: 1500K total
res-base Wins GCs Fnts Pxms Misc Pxm mem Other Total PID Identifier
0e00000 7 30 2 8 27 1378K 3K 1381K 2293 main_app
0c00000 67 8 1 38 840 87K 22K 109K ? <unknown>
0800000 2 7 6 1 22 0B 6K 6K 1647 uxterm
0000000 1 0 2 0 36 0B 2K 2K ? <unknown>
0a00000 2 1 0 0 1 0B 96B 96B ? <unknown>
1000000 1 1 0 0 0 0B 48B 48B ? xrestop
0400000 1 1 0 0 0 0B 48B 48B ? <unknown>
0600000 0 1 0 0 0 0B 24B 24B ? <unknown>
0200000 0 1 0 0 0 0B 24B 24B ? <unknown>
我不知道为什么 xorg 不断增长。请给我一些关于在哪里寻找和寻找什么的指示。
我在 Debian Linux 上: debian:~# uname -a Linux debian 2.6.32-5-686 #1 SMP Tue Mar 8 21:36:00 UTC 2011 i686 GNU/Linux debian:~#
英特尔(R) Atom(TM) CPU N270 @ 1.60GHz
以下是 xorg 进程的 pmap 输出。有趣的是,总数为 1.1GB,但单个条目的总和并不算多。
debian:~# pmap -x 1598 | more
1598: /usr/bin/X :0 -br -nocursor -auth /tmp/serverauth.O1gWpWvWuP
Address Kbytes RSS Dirty Mode Mapping
08048000 0 404 0 r-x-- Xorg
081e3000 0 24 12 rw--- Xorg
081ef000 0 40 24 rw--- [ anon ]
08231000 0 36188 35232 rw--- [ anon ]
b5422000 0 1892 1888 rw--- [ anon ]
b59a1000 0 384 0 rw-s- [ shmid=0x520000 ]
b5bd6000 0 0 0 rw--- [ anon ]
b5e85000 0 0 0 r-x-- libexpat.so.1.5.2
b5ea9000 0 0 0 rw--- libexpat.so.1.5.2
b5eab000 0 0 0 r-x-- evdev_drv.so
b5eb3000 0 0 0 rw--- evdev_drv.so
b5eb4000 0 0 0 r-x-- swrast_dri.so
b60c8000 0 0 0 rw--- swrast_dri.so
b60cd000 0 1876 1876 rw--- [ anon ]
b6f83000 0 3072 0 rw-s- fb0
b7283000 0 8 0 r-x-- libshadow.so
b7288000 0 4 4 rw--- libshadow.so
b7289000 0 56 0 r-x-- libfb.so
b72a6000 0 4 4 rw--- libfb.so
b72a7000 0 0 0 r-x-- libfbdevhw.so
b72ab000 0 0 0 rw--- libfbdevhw.so
b72ac000 0 4 0 r-x-- fbdev_drv.so
b72b0000 0 4 0 rw--- fbdev_drv.so
b72b1000 0 0 0 r-x-- librecord.so
b72b7000 0 0 0 rw--- librecord.so
b72b8000 0 12 0 r-x-- libglx.so
b7307000 0 8 0 rw--- libglx.so
b730a000 0 12 0 r-x-- libselinux.so.1
b7323000 0 0 0 r---- libselinux.so.1
b7324000 0 0 0 rw--- libselinux.so.1
b7325000 0 0 0 r-x-- libextmod.so
b7341000 0 4 4 rw--- libextmod.so
b7343000 0 0 0 r-x-- libdrm.so.2.4.0
b734c000 0 0 0 rw--- libdrm.so.2.4.0
b734d000 0 0 0 r-x-- libdri.so
b7355000 0 0 0 rw--- libdri.so
b7356000 0 0 0 r-x-- libgcc_s.so.1
b7373000 0 0 0 rw--- libgcc_s.so.1
b7374000 0 4 4 rw--- [ anon ]
b7376000 0 0 0 r-x-- libgpg-error.so.0.4.0
b7379000 0 0 0 rw--- libgpg-error.so.0.4.0
b737a000 0 0 0 r-x-- libfontenc.so.1.0.0
b737f000 0 0 0 rw--- libfontenc.so.1.0.0
b7380000 0 0 0 r-x-- libbz2.so.1.0.4
b7390000 0 0 0 rw--- libbz2.so.1.0.4
b7391000 0 0 0 r-x-- libfreetype.so.6.6.0
b7404000 0 0 0 rw--- libfreetype.so.6.6.0
b7408000 0 0 0 r-x-- libz.so.1.2.3.4
b741b000 0 0 0 rw--- libz.so.1.2.3.4
b741c000 0 0 0 rw--- [ anon ]
b741d000 0 128 0 r-x-- libc-2.11.2.so
b755d000 0 4 0 r---- libc-2.11.2.so
b755f000 0 4 0 rw--- libc-2.11.2.so
b7560000 0 8 4 rw--- [ anon ]
b7563000 0 8 0 r-x-- librt-2.11.2.so
b756a000 0 4 0 r---- librt-2.11.2.so
b756b000 0 0 0 rw--- librt-2.11.2.so
b756c000 0 4 0 r-x-- libm-2.11.2.so
b7590000 0 0 0 r---- libm-2.11.2.so
b7591000 0 0 0 rw--- libm-2.11.2.so
b7592000 0 0 0 r-x-- libaudit.so.0.0.0
b75a9000 0 4 0 r---- libaudit.so.0.0.0
b75aa000 0 0 0 rw--- libaudit.so.0.0.0
b75ab000 0 0 0 r-x-- libgcrypt.so.11.5.3
b761c000 0 8 4 rw--- libgcrypt.so.11.5.3
b761f000 0 0 0 r-x-- libXdmcp.so.6.0.0
b7623000 0 0 0 rw--- libXdmcp.so.6.0.0
b7624000 0 0 0 rw--- [ anon ]
b7625000 0 72 0 r-x-- libpixman-1.so.0.16.4
b767c000 0 8 0 rw--- libpixman-1.so.0.16.4
b767e000 0 0 0 r-x-- libXau.so.6.0.0
b7680000 0 0 0 rw--- libXau.so.6.0.0
b7681000 0 8 0 r-x-- libXfont.so.1.4.1
b76b5000 0 0 0 rw--- libXfont.so.1.4.1
b76b7000 0 12 0 r-x-- libpthread-2.11.2.so
b76cc000 0 4 0 r---- libpthread-2.11.2.so
b76cd000 0 0 0 rw--- libpthread-2.11.2.so
b76ce000 0 0 0 rw--- [ anon ]
b76d0000 0 4 0 r-x-- libdl-2.11.2.so
b76d2000 0 4 0 r---- libdl-2.11.2.so
b76d3000 0 0 0 rw--- libdl-2.11.2.so
b76d4000 0 4 0 rw--- [ anon ]
b76d5000 0 0 0 r-x-- libpciaccess.so.0.10.8
b76dc000 0 0 0 rw--- libpciaccess.so.0.10.8
b76dd000 0 4 0 r-x-- libudev.so.0.9.3
b76e9000 0 0 0 r---- libudev.so.0.9.3
b76ea000 0 0 0 rw--- libudev.so.0.9.3
b76eb000 0 0 0 r-x-- libdri2.so
b76ed000 0 0 0 rw--- libdri2.so
b76ee000 0 16 0 r-x-- libdbe.so
b76f2000 0 4 0 rw--- libdbe.so
b76f3000 0 4 0 rw--- [ anon ]
b76f6000 0 4 0 r-x-- [ anon ]
b76f7000 0 8 0 r-x-- ld-2.11.2.so
b7712000 0 0 0 r---- ld-2.11.2.so
b7713000 0 0 0 rw--- ld-2.11.2.so
bfcb7000 0 16 16 rw--- [ stack ]
-------- ------- ------- ------- -------
total kB 1197560 - - -
debian:~#
pmap -d 显示针对匿名映射映射的 1.1GB。
debian:~# pmap -d 1598 | more
1598: /usr/bin/X :0 -br -nocursor -auth /tmp/serverauth.O1gWpWvWuP
Address Kbytes Mode Offset Device Mapping
08048000 1644 r-x-- 0000000000000000 008:00001 Xorg
081e3000 48 rw--- 000000000019b000 008:00001 Xorg
081ef000 44 rw--- 0000000000000000 000:00000 [ anon ]
08231000 1164236 rw--- 0000000000000000 000:00000 [ anon ]
b5422000 3752 rw--- 0000000000000000 000:00000 [ anon ]
b59a1000 384 rw-s- 0000000000000000 000:00004 [ shmid=0x520000 ]
我现在需要一种方法来识别地址 08231000 的所有者。
控制器如下所示。
debian:~# lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GME Express Integrated Graphics Controller (rev 03)
debian:~#
Debian:~#
Xorg加载的模块如下:
debian:~# grep -i "Loading" /var/log/Xorg.0.log
(II) Loading /usr/lib/xorg/modules/extensions/libdbe.so
(II) Loading extension DOUBLE-BUFFER
(II) Loading /usr/lib/xorg/modules/extensions/libdri2.so
(II) Loading extension DRI2
(II) Loading /usr/lib/xorg/modules/extensions/libextmod.so
(II) Loading extension SELinux
(II) Loading extension MIT-SCREEN-SAVER
(II) Loading extension XFree86-VidModeExtension
(II) Loading extension XFree86-DGA
(II) Loading extension DPMS
(II) Loading extension XVideo
(II) Loading extension XVideo-MotionCompensation
(II) Loading extension X-Resource
(II) Loading /usr/lib/xorg/modules/extensions/libdri.so
(II) Loading extension XFree86-DRI
(II) Loading /usr/lib/xorg/modules/extensions/libglx.so
(II) Loading extension GLX
(II) Loading /usr/lib/xorg/modules/extensions/librecord.so
(II) Loading extension RECORD
(II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
(II) Loading sub module "fbdevhw"
(II) Loading /usr/lib/xorg/modules/linux/libfbdevhw.so
(II) Loading sub module "fb"
(II) Loading /usr/lib/xorg/modules/libfb.so
(II) Loading sub module "shadow"
(II) Loading /usr/lib/xorg/modules/libshadow.so
(II) Loading /usr/lib/xorg/modules/input/evdev_drv.so
debian:~#
debian:~# /usr/bin/Xorg -version
X.Org X Server 1.7.7
Release Date: 2010-05-04
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.32.29-dsa-ia32 i686 Debian
Current Operating System: Linux debian 2.6.32-5-686 #1 SMP Tue Mar 8 21:36:00 UTC 2011 i686
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-2.6.32-5-686 root=/dev/sda1 nomodeset
Build Date: 19 February 2011 02:37:36PM
xorg-server 2:1.7.7-13 (Cyril Brulebois <[email protected]>)
Current version of pixman: 0.16.4
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
debian:~#
答案1
我在5.0版本之后使用VirtualBox时也遇到同样的问题。 Xorg进程内存将缓慢但稳定地增加到6G。
我禁用了mit-shm
选项来xorg.conf
解决问题。您可以添加以下选项:
Section "Extensions"
Option "MIT-SHM" "disable"
EndSection