Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 57937 - X memory leak with nvidia driver
Summary: X memory leak with nvidia driver
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: x86 All
: High major (vote)
Assignee: Gentoo X packagers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-22 00:30 UTC by brian tarricone
Modified: 2004-08-05 18:09 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description brian tarricone 2004-07-22 00:30:02 UTC
i'm not sure if the nvidia driver is related, but i figure i'll throw it into the summary anyway, as it seems a likely culprit.  X is consuming more and more memory after it's been running for a while.  from a fresh start (launched from GDM), X consumes around 80MB (as reported 'VM Size' via gnome-system-monitor).  now, after several days, X is reportedly using 459MB, and this is after i've closed all X apps (aside from firefox).  the latest ballooning occured after i just used vmware (right before that, X memory usage was around 350MB).  'free' reports the following:

             total       used       free     shared    buffers     cached
Mem:        644448     627540      16908          0      16224      40064
-/+ buffers/cache:     571252      73196
Swap:      1004020     372492     631528

'top' reports X's resource usage as:

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
8314 root      16   0  461m 270m  51m R 17.6 43.0 678:44.95 X

using/running any app results in aggressive swapping to disk.  xorg-x11 is 6.7.0-r2, nvidia-kernel is 1.0.6106, and nvidia-glx is 1.0.6106-r3.  the same thing happens with xfree, and i believe the version there is 4.3.0-r6 (it's my machine at work; i don't have access to it at the moment).

emerge --info reports:

Portage 2.0.50-r9 (default-x86-1.4, gcc-3.3.4, glibc-2.3.4.20040619-r0, 2.6.7-gentoo-r8)
=================================================================
System uname: 2.6.7-gentoo-r8 i686 AMD Athlon(tm) processor
Gentoo Base System version 1.5.1
ccache version 2.2 [enabled]
Autoconf: sys-devel/autoconf-2.59-r4
Automake: sys-devel/automake-1.8.5-r1
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CFLAGS="-march=athlon-tbird -O2 -pipe -falign-functions=4 -ffast-math"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /etc/tomcat /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.1/share/config /usr/kde/3.2/share/config /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-march=athlon-tbird -O2 -pipe -falign-functions=4 -ffast-math"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache sandbox"
GENTOO_MIRRORS="http://gentoo.seren.com/gentoo http://mirror.datapipe.net/gentoo http://gentoo.mirrors.pair.com/ http://mirror.datapipe.net/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
USE="3dnow X aalib acpi4linux alsa apache2 apm avi berkdb bonobo cdr crypt cups 
curl directfb dvd dvdr encode esd fam fbcon ffmpeg flash foomaticdb gdbm gif 
gnome gphoto2 gpm gtk gtk2 gtkhtml guile imlib innodb java joystick jpeg 
kerberos krb4 ldap libg++ libwww mad mikmod mmx motif mpeg mysql ncurses nls 
nvidia oggvorbis opengl oss pam pdflib perl pic png python qt quicktime readline
samba sasl sdl slang spell ssl stencil-buffer svga tcltk tcpd tetex theora tiff 
truetype ungif usb v4l2 x86 xchattext xfs xml xml2 xmms xv xvid zlib"
Comment 1 brian tarricone 2004-07-22 00:38:35 UTC
ok, i just restarted X, and it looks like i was mistaken on the initial memory usage, as it's a bit lower than i thought.  from 'top':

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
9831 root      15   0 53480  17m  45m S  0.7  2.7   0:09.20 X

and 'free' reports:

             total       used       free     shared    buffers     cached
Mem:        644448     377588     266860          0      25972     169796
-/+ buffers/cache:     181820     462628
Swap:      1004020      32424     971596

(note that i ran a quick update/recompile of my session manager while X was sitting at the GDM login screen, hence the high buffer/cache value.)
Comment 2 Donnie Berkholz (RETIRED) gentoo-dev 2004-07-22 00:55:23 UTC
Try something cool like x11-misc/xrestop over time.
Comment 3 brian tarricone 2004-07-22 01:35:27 UTC
all right, here goes.  shortly after X startup.  running:
* thunderbird
* 2 Eterms (one with top, other with xrestop)
* gaim
* xchat
* gedit
* xfce4-cvs

top says:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  23066 root      15   0 55452  19m  46m S  7.3  3.0   0:12.94 X

xrestop says:

xrestop - Display: localhost:0
          Monitoring 16 clients. XErrors: 0
          Pixmaps:   13190K total, Other:     158K total, All:   13349K total

res-base Wins  GCs Fnts Pxms Misc   Pxm mem  Other   Total   PID Identifier    
1000000   107   38    0    3   28     7884K      4K   7888K   ?   Desktop
0c00000   141   28    1  191 3855     1431K     95K   1526K 23128 xfwm4
1e00000    42   29    8   38    9      610K      9K    620K   ?   brian@kelnos:~
1200000    86   41    0   32   23      478K      3K    481K   ?   Xfce Panel
1800000    85   34    1   45   39      420K      4K    425K   ?   Inbox for bjt2
1600000    42   29    8   28    9      403K      9K    413K   ?   brian@kelnos:~
1c00000    72   49    1    6   24      407K      4K    411K   ?   X-Chat [2.0.10
1a00000    49   22    1    4   13      393K      2K    396K   ?   Untitled 1 (mo
1400000    23   21    1    4   14      393K      2K    395K   ?   Buddy List
0800000     2    1    1    1   35      384K      1K    385K 23093 xfce4-session
0e00000    20   20    0    2   27      384K      1K    385K   ?   Task List
0400000     1    1    0    0  679        0B     15K     15K   ?   screensaver
0200000     0    1    1    0    0        0B      1K      1K   ?   <unknown>
0a00000     4    1    0    0   19        0B    576B    576B 23124 xfce-mcs-manag
0600000     2    1    0    0   20        0B    552B    552B 23119 devilspie
2000000     1    1    0    0    0        0B     48B     48B   ?   xrestop

next, we add:
* another 15 Eterms
* anjuta (3 instances, each with 10-20 files open)
* pan, viewing a newsgroup with several thousand articles

top says:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
23066 root      15   0  242m  70m  49m S 34.1 11.2   1:15.04 X

xrestop says:

xrestop - Display: localhost:0
          Monitoring 35 clients. XErrors: 0
          Pixmaps:  178840K total, Other:     718K total, All:  179559K total

res-base Wins  GCs Fnts Pxms Misc   Pxm mem  Other   Total   PID Identifier    
4400000   286  146    1  130 3950    73602K    103K  73706K   ?   Anjuta: /munch
2c00000   202   86    1   70 1133    38487K     34K  38522K   ?   Anjuta: /munch
3800000   202   86    1   70 1130    38468K     34K  38502K   ?   Anjuta: /munch
1000000   107   38    0    3   51     7884K      4K   7888K   ?   Desktop
0c00000   426   28    1  475 11645     5794K    284K   6079K 23128 xfwm4
2800000    42   29    8   28    9     1901K      9K   1911K   ?   brian@kelnos:~
3600000    42   29    8   26    9     1885K      9K   1895K   ?   brian@kelnos:~
2e00000    42   29    8   26    9      847K      9K    857K   ?   brian@kelnos:~
3200000    42   29    8   26    9      804K      9K    814K   ?   brian@kelnos:~
1e00000    42   29    8   42    9      711K      9K    721K   ?   brian@kelnos:~
2a00000    42   29    8   26    9      606K      9K    616K   ?   brian@kelnos:~
4a00000   167   28    1   39   33      591K      6K    597K   ?   alt.binaries.s
4200000    42   29    8   46    9      484K      9K    494K   ?   brian@kelnos:~
1200000    88   41    0   32   23      478K      3K    481K   ?   Xfce Panel
1600000    42   29    8   32    9      423K      9K    433K   ?   brian@kelnos:~
1800000    85   34    1   45   39      420K      4K    425K   ?   Inbox for bjt2
1c00000    72   49    1    6   24      407K      4K    411K   ?   X-Chat [2.0.10
3c00000    42   29    8   26    9      399K      9K    409K   ?   brian@kelnos:~
3a00000    42   29    8   26    9      399K      9K    409K   ?   brian@kelnos:~
3400000    42   29    8   26    9      399K      9K    409K   ?   brian@kelnos:~
2600000    42   29    8   26    9      399K      9K    409K   ?   brian@kelnos:~
2200000    42   29    8   26    9      399K      9K    409K   ?   brian@kelnos:~
1a00000    49   22    1    4   13      393K      2K    396K   ?   Untitled 1 (mo
1400000    23   21    1    4   14      393K      2K    395K   ?   Buddy List
0800000     2    1    1    1   58      384K      2K    386K 23093 xfce4-session
0e00000    20   20    0    2   50      384K      2K    386K   ?   Task List
4000000    42   29    8   28    9      373K      9K    383K   ?   brian@kelnos:~
3e00000    42   29    8   26    9      371K      9K    381K   ?   brian@kelnos:~
3000000    42   29    8   26    9      371K      9K    381K   ?   brian@kelnos:~
2400000    42   29    8   26    9      371K      9K    381K   ?   brian@kelnos:~
0400000     1    1    0    0 2454        0B     57K     57K   ?   screensaver
0a00000     4    1    0    0   42        0B      1K      1K 23124 xfce-mcs-manag
0600000     2    1    0    0   43        0B      1K      1K 23119 devilspie
0200000     0    1    1    0    0        0B      1K      1K   ?   <unknown>
2000000     1    1    0    0    0        0B     48B     48B   ?   xrestop

next i close all the new stuff so i'm left with the same setup as i have with
the first set of apps running.

top says:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
23066 root      15   0 94144  56m  46m S 12.3  9.0   1:44.59 X

xrestop says:

xrestop - Display: localhost:0
          Monitoring 16 clients. XErrors: 21
          Pixmaps:   13411K total, Other:     158K total, All:   13570K total

res-base Wins  GCs Fnts Pxms Misc   Pxm mem  Other   Total   PID Identifier    
1000000   107   38    0    3   28     7884K      4K   7888K   ?   Desktop
0c00000   141   28    1  191 3855     1488K     95K   1584K 23128 xfwm4
1e00000    42   29    8   46    9      754K      9K    764K   ?   brian@kelnos:~
1200000    88   41    0   32   23      478K      3K    481K   ?   Xfce Panel
1600000    42   29    8   32    9      423K      9K    433K   ?   brian@kelnos:~
1800000    85   34    1   45   39      420K      4K    425K   ?   Inbox for bjt2
1c00000    72   49    1    6   24      407K      4K    411K   ?   X-Chat [2.0.10
1a00000    49   22    1    4   13      393K      2K    396K   ?   Untitled 1 (mo
1400000    23   21    1    4   14      393K      2K    395K   ?   Buddy List
0800000     2    1    1    1   35      384K      1K    385K 23093 xfce4-session
0e00000    20   20    0    2   27      384K      1K    385K   ?   Task List
0400000     1    1    0    0  682        0B     16K     16K   ?   screensaver
0200000     0    1    1    0    0        0B      1K      1K   ?   <unknown>
0a00000     4    1    0    0   19        0B    576B    576B 23124 xfce-mcs-manag
0600000     2    1    0    0   20        0B    552B    552B 23119 devilspie
2000000     1    1    0    0    0        0B     48B     48B   ?   xrestop


so, X memory usage (as reported by top) has gone from 55MB -> 242MB -> 94MB.
xrestop, however, reports almost the exact same data in the first run as in the
last run.  'free' reports about 265MB used (this is _without_ buffers/cache
included).

on a hunch, i checked out opengl.  i opened up the xscreensaver settings panel,
and clicked 'preview' for GLmatrix.  top reported X memory jumped up to 110MB,
but only dropped down to about 98MB after i closed the settings panel.
however, repeatedly opening and closing the panel and clicking preview didn't
cause any more of an increase (the final value was always 98MB).

i'll report back in a day or two after i have some "real-world" usage.
Comment 4 Andrew Bevitt 2004-07-22 23:09:20 UTC
You know I think you might find that things are normal

This is top for my machine right now
 (firefox two tabs, amsn, two aterms, irssi in one aterm top in the other, xmms playing 128kbps, kmail, fluxbox, and an xterm)

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
 8794 root      15   0  211m  78m 139m S  0.7  8.9  18:58.63 X                  

See my reading of this is that X currently NEEDS 78M which is reasonablish i think, and that it has 139M (78 + 139 = 217 ie the two make the virtual) in buffer/cache

             total       used       free     shared    buffers     cached
Mem:        906320     336712     569608          0      18016     131596
-/+ buffers/cache:     187100     719220
Swap:       996020       2508     993512

Apparently I have currently got 330M used up RAM wise, but thats with 180M in cache/buffering so thats about 150M for current usage.

xrestop - Display: localhost:0
          Monitoring 19 clients. XErrors: 0
          Pixmaps:   65701K total, Other:     127K total, All:   65829K total
<snipped for berevity kmail is fun>
Which more or less agrees with the top values.. 

Now my system has been up for 20hours or so 18 with X running, ive done several screensaver (opengl / nvidia) sessions, played few tunes and done some uni course work ... so ive done basically the same stuff as you... 

Yet my buffers are no where near as high as yours... like yours are 500+M ish

But we can also see that the actual non buffered memory does drop down again.. if it truly were a leak you wouldnt recover the memory (i think) it would stay in the USED section... 

So you must have a run-a-way process or something that is doing it in my oppinion no idea what to be honest though...
Comment 5 brian tarricone 2004-07-23 14:57:41 UTC
annoyingly, now that i try to reproduce it for bugzilla, i'm not having a problem. i've been using the machine for the past day and a half as usual, and i just went and closed all apps (except gaim and xchat), and X memory usage dropped back down to 98MB.

i'm not really sure that your reaing of the top output is correct.  i don't think that processes have buffer/cache memory.  the kernel does, but the VIRT column should be a count of all RAM that the process has allocated.  RES is the amount that's actually resident in non-swapped memory.  SHR should be the amount of RAM shared with other processes (e.g., non-writeable sections of shared libraries, etc.).  of course i could be wrong, but i don't think so.

now, before, when i could actually reproduce this, i'd get to the point that if i closed all X apps (except for the desktop), my memory usage (as reported by 'free') would be only 10MB short of all my phys RAM, a very small amount (<20MB) as buffers/cache.  in addition, half of my swap was full.  at that point, simply opening an Eterm would cause a lot of HD thrashing and would take between 10 and 20 seconds (a bit much on an athlon 1.33 with 640MB of ram).  at that point, looking at top would tell me that X was indeed consuming most of my RAM (via the VIRT column).  restarting X brought everything back to normal.

as for a runaway process, i don't think so.  when i was having problems, X clearly was consuming all of my RAM, and no other processes came even close (the #2 spot was claimed by an app using 18MB).

now, before i reported this, i did a couple google searches, and found something that mentioned that after installing a newer version of xfree, they experienced memory leaks until they recompiled fontconfig.  this seemed a bit out there and strange, but i said "hey, can't hurt" and reemerged fontconfig.  so, if that was indeed the issue, that could be why i'm not seeing any problems now.
Comment 6 Andrew Bevitt 2004-08-05 18:09:58 UTC
Well if it re-occurs reopen the bug.