X leaks memory

Patrick O'Callaghan poc at usb.ve
Mon Sep 1 14:16:42 UTC 2008


A few days ago I was casually running htop and noticed that the X server
seemed to be consuming an inordinate amount of memory. Since I normally
leave my session logged in for days at a time, I logged out and the
usage immediately dropped to a fraction of what it was. I decided to
monitor the usage with the following script (run from a root console):

        #!/bin/sh
        X=`pgrep -f /usr/bin/X`
        period=1800
        mkdir -p /tmp/Xleak
        
        while :
        do
                stamp=`date +%F_%R`
                grep Vm* /proc/$X/status > /tmp/Xleak/$stamp
                sleep $period
        done

(this just copies some statistics from the /proc/<pid>/status file to a
time-stamped log file every 30 minutes).

The results are interesting. Between 5:30pm yesterday and 9am today the
usage as reflected by the VmSize statistic went from 450952 KB to
1241608 KB, i.e. almost tripled. It's worth noting that the running apps
over this period basically didn't change: evolution, a few Firefox
windows, a couple of terminal consoles, a Ktorrent session and a
quiescent Pidgin session.

The 'xrestop' tool shows total consumption for all 39 clients of X to be
46464 KB (the top user is kwin with under 20MB).

The Xleak stats show long periods of no change, which seem to correspond
to me not using the machine, with occasional increases and no decreases.
It seems fairly clear to me that X is leaking memory. I also collected
stats from /proc/<pid>/smaps but the process memory map never changes.

I suspect this explains why I've found my system to start becoming
sluggish after a few days use, something which has been bothering me for
months. Monitoring the situation with htop is illuminating: cpu usage
rarely goes over 10%, but whereas in a new session I'm not using any
swap space, after a day or two swap is being used more and more, and
eventually fills up completely. Not good.

This is F9 with an 2.6.25.14-108.fc9.x86_64 kernel on an Intel 965
motherboard, 2GB of RAM, onboard video chipset, running
xorg-x11-server-Xorg-1.4.99.905-2.20080702.fc9.x86_64 and
xorg-x11-drv-i810-2.3.2-2.fc9.x86_64 under KDE 4.1.

Has anyone seen this behaviour, or should I bump it upstream, and if so
where to? BZ has some reports of apparent leakage (e.g.
https://bugzilla.redhat.com/show_bug.cgi?id=448503) but I'm not sure
it's the same phenomenon.

poc




More information about the fedora-list mailing list