# FreeBSD 7.0-RELEASE-p4 && xorg-7.3_2 huge memory leak



## TheFeaR (Nov 17, 2008)

Hi all!

I have i trouble, that I cant solve for a long time!specifically I run a FreeBSD as a work desktop, and my Xorg process have a huge memory leak up to 2Gb for a one day of work! and I dont understand why. 

"Xrestop" tool dont show me which part/module demand so much memory.

I use dual monitor configuration(XRandr), WM -Enlightenment(e17).

```
[root@kirill]#pkg_info|grep xorg
linux-xorg-libs-6.8.2_5 Xorg libraries, linux binaries
xorg-7.3_2          X.Org complete distribution metaport
xorg-apps-7.3       X.org apps meta-port
xorg-cf-files-1.0.2_2 X.org cf files for use with imake builds
xorg-docs-1.4,1     X.org documentation files
xorg-drivers-7.3_3  X.org drivers meta-port
xorg-libraries-7.3_2 X.org libraries meta-port
xorg-protos-7.3_2   X.org protos meta-port
xorg-server-1.4.2,1 X.Org X server and related programs
```


```
pkg_info|grep font

bdftopcf-1.0.1      Convert X font from BDF to PCF
bitstream-vera-1.10_4 Bitstream Vera TrueType font collection
cmpsfont-1.0_6      Computer Modern PostScript Fonts (Adobe Type 1 format)
encodings-1.0.2,1   X.Org Encoding fonts
font-adobe-100dpi-1.0.0_1 X.Org Adobe 100dpi font
font-adobe-75dpi-1.0.0 X.Org Adobe 75dpi font
font-adobe-utopia-100dpi-1.0.1 X.Org Adobe Utopia 100dpi font
font-adobe-utopia-75dpi-1.0.1 X.Org Adobe Utopia 75dpi font
font-adobe-utopia-type1-1.0.1 X.Org Adobe Utopia Type1 font
font-alias-1.0.1    X.Org Font aliases
font-arabic-misc-1.0.0 X.Org miscellaneous Arabic fonts
font-bh-100dpi-1.0.0 X.Org Bigelow Holmes 100dpi font
font-bh-75dpi-1.0.0 X.Org Bigelow Holmes 75dpi font
font-bh-lucidatypewriter-100dpi-1.0.0 X.Org Bigelow Holmes Lucida TypeWriter 100dpi font
font-bh-lucidatypewriter-75dpi-1.0.0 X.Org Bigelow Holmes Lucida TypeWriter 75dpi font
font-bh-ttf-1.0.0   X.Org Bigelow & Holmes TTF font
font-bh-type1-1.0.0 X.Org Bigelow Holmes Type1 font
font-bitstream-100dpi-1.0.0 X.Org Bitstream Vera 100dpi font
font-bitstream-75dpi-1.0.0 X.Org Bitstream Vera 75dpi font
font-bitstream-type1-1.0.0 X.Org Bitstream Vera Type1 font
font-cronyx-cyrillic-1.0.0 X.Org Cronyx Cyrillic font
font-cursor-misc-1.0.0 X.Org miscellaneous Cursor fonts
font-daewoo-misc-1.0.0 X.Org miscellaneous Daewoo fonts
font-dec-misc-1.0.0 X.Org miscellaneous Dec fonts
font-ibm-type1-1.0.0 X.Org IBM Type1 font
font-isas-misc-1.0.0 X.Org miscellaneous ISAS fonts
font-jis-misc-1.0.0 X.Org miscellaneous JIS fonts
font-micro-misc-1.0.0 X.Org miscellaneous Micro fonts
font-misc-cyrillic-1.0.0 X.Org miscellaneous Cyrillic font
font-misc-ethiopic-1.0.0 X.Org miscellaneous Ethiopic font
font-misc-meltho-1.0.0_1 X.Org miscellaneous Meltho font
font-misc-misc-1.0.0 X.Org miscellaneous Misc fonts
font-mutt-misc-1.0.0 X.Org miscellaneous Mutt fonts
font-schumacher-misc-1.0.0 X.Org miscellaneous Schumacher fonts
font-screen-cyrillic-1.0.1 X.Org Screen Cyrillic font
font-sony-misc-1.0.0 X.Org miscellaneous Sony fonts
font-sun-misc-1.0.0 X.Org miscellaneous Sun fonts
font-util-1.0.1     Create an index of X font files in a directory
font-winitzki-cyrillic-1.0.0 X.Org Winitzki Cyrillic font
font-xfree86-type1-1.0.0 X.Org XFree86 Type1 font
fontcacheproto-0.1.2 Fontcache extension headers
fontconfig-2.5.0,1  An XML-based font configuration API for X Windows
fontsproto-2.0.2    Fonts extension headers
fonttosfnt-1.0.3    Wrap a bitmap font in a sftn wrapper
freetype2-2.3.7     A free and portable TrueType font rendering engine
fslsfonts-1.0.1     List fonts served by the X font server
fstobdf-1.0.2       Generate BDF font from X font server
gsfonts-8.11_4      Fonts used by GNU Ghostscript (or X)
libXfont-1.3.1_3,1  X font libary
libXfontcache-1.0.4 The Xfontcache library
libXft-2.1.13       A client-sided font API for X applications
libfontenc-1.0.4    The fontenc Library
linux-fontconfig-2.2.3_7 Linux/i386 binary of Fontconfig
mkbold-mkitalic-0.11_1 Programs to make BDF font bold/italic
mkfontdir-1.0.3_1   Create an index of X font files in a directory
mkfontscale-1.0.3   Creates an index of scalable font files for X
p5-type1inst-0.6.1_5 A script that helps install Postscript fonts in X Window Sy
showfont-1.0.1_1    Font dumper for the X font server
terminus-font-4.20_5 Terminus Font - a clean fixed width font
webfonts-0.30_5     TrueType core fonts for the Web
xf86bigfontproto-1.1.2 XFree86-Bigfont extension headers
xfd-1.0.1           Display all characters in an X font
xfontsel-1.0.2      Point and click selection of X11 font names
xfs-1.0.5_1,1       X.Org font server
xfsinfo-1.0.1       X font server information utility
xlsfonts-1.0.2      Server font list displayer for X
xorg-fonts-100dpi-7.3 X.Org 100dpi bitmap fonts
xorg-fonts-7.3_1    X.org fonts meta-port
xorg-fonts-75dpi-7.3 X.Org 75dpi bitmap fonts
xorg-fonts-cyrillic-7.3 X.Org Cyrillic bitmap fonts
xorg-fonts-miscbitmaps-7.3 X.Org miscellaneous bitmap fonts
xorg-fonts-truetype-7.3 X.Org TrueType fonts
xorg-fonts-type1-7.3 X.Org Type1 fonts
```


```
cat /etc/X11/xorg.conf
Section "ServerLayout"
        Identifier     "X.org Configured"
        Screen      0  "Screen0" 0 0
        InputDevice    "Mouse0" "CorePointer"
        InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
        RgbPath      "/usr/local/share/X11/rgb"
        ModulePath   "/usr/local/lib/xorg/modules"
        FontPath     "/usr/local/lib/X11/fonts/misc/"
        FontPath     "/usr/local/lib/X11/fonts/TTF/"
        FontPath     "/usr/local/lib/X11/fonts/OTF"
        FontPath     "/usr/local/lib/X11/fonts/Type1/"
        FontPath     "/usr/local/lib/X11/fonts/100dpi/"
        FontPath     "/usr/local/lib/X11/fonts/75dpi/"
        FontPath     "/usr/local/lib/X11/fonts/webfonts"
        FontPath     "/usr/local/lib/X11/fonts/cyrillic"
        FontPath     "/usr/local/lib/X11/fonts/dejavu/"
        FontPath     "/usr/local/lib/X11/fonts/terminus-font/"
EndSection

Section "Module"
        Load  "dbe"
        Load  "glx"
        Load  "GLcore"
        Load  "xtrap"
        Load  "dri"
#       Load  "freetype"
        Load  "type1"
EndSection

Section "InputDevice"
        Identifier  "Keyboard0"
        Driver      "kbd"
        Option "XkbLayout" "us,ru(winkeys)"
        Option "XKbOptions" "grp:ctrl_shift_toggle,grp_led:scroll"
EndSection

Section "InputDevice"
        Identifier  "Mouse0"
        Driver      "mouse"
        Option      "Protocol" "auto"
        Option      "Device" "/dev/sysmouse"
        Option      "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
        #DisplaySize      340   270     # mm
        Identifier   "Monitor0"
        VendorName   "BNQ"
        ModelName    "BenQ FP73G"
 ### Comment all HorizSync and VertRefresh values to use DDC:
        HorizSync    31.0 - 83.0
        VertRefresh  56.0 - 76.0
        Option      "DPMS"
EndSection

Section "Device"
        Identifier  "Card0"
        Driver      "radeon"
        VendorName  "ATI Technologies Inc"
        BoardName   "RV410 [Radeon X700 Pro (PCIE)]"
        BusID       "PCI:1:0:0"
        Option "RenderAccel" "true"
EndSection

Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
        SubSection "Display"
                Viewport   0 0
                Depth     24
                Virtual 2560 1024
        EndSubSection
EndSection


Section "DRI"
        Mode 0666
EndSection
```


```
Xorg working above 2 hours.
19765 root          1  96    0   459M   238M select   4:57  2.44% Xorg
```
Any suggestions?


----------



## aragon (Nov 18, 2008)

Not sure, but my Xorg config is similar to yours and I don't have any leaking.  I don't use DRI though.  Perhaps try disable that and see what happens...


----------



## TheFeaR (Nov 18, 2008)

I already try to disable that extension, but there is no effect.

I think it is one of the fonts, or something are reserving memory, because memory starts leaking while i browsing internet, but it is not trouble of browser( i also try Opera).


----------



## billt (Nov 18, 2008)

Have you tried using another window manager?

That is, are you sure the problem is with X and not with the window manager?


----------



## TheFeaR (Nov 18, 2008)

I have a friends, using enlightenment with dualhead configuration too. they dont have that problem.


----------



## danger@ (Nov 18, 2008)

your friends might be using a different version.


----------



## TheFeaR (Nov 18, 2008)

no, unfortunately Enlightenmet ( E17 DEVEL edition) is updating not so frequently. So I am sure that my friend use a similar version. I remember! I also trying to use a AwesomeWM. Have a same trouble. So I am sure, that the trouble is somewhere inside of Xorg, or modules, or font daemon.

Today i try to recompile a freetype ( Last time i compile it i change a source for a little(turn ON bytecode interpreter)) i hope that can help, but it isnt. Still leaking.


Anyway thank you all for trying! I am appreciate it. ?e


----------



## richardpl (Nov 18, 2008)

Post output of "vmstat -m"


----------



## TheFeaR (Nov 19, 2008)

```
1248 root          1  97    0   628M   400M select   7:05 15.62% Xorg
```
(working 1 hour)


```
[root@kirill]#vmstat -m
         Type InUse MemUse HighUse Requests  Size(s)
      scsi_cd     0     0K       -        5  16
         cdev    24     3K       -       24  128
CAM dev queue     3     1K       -        3  64
       kbdmux     6     9K       -        6  16,128,256,2048,4096
        sigio     3     1K       -        3  32
filedesc_to_leader     0     0K       -       68  32
     filedesc   152    63K       -     3643  16,32,64,128,256,512,1024,2048,4096
         kenv   115     8K       -      117  16,32,64,4096
       kqueue     6    11K       -     3305  128,1024,2048,4096
    proc-args    57     5K       -     2027  16,32,64,128,256
      ithread    73     6K       -       73  16,64,128
       KTRACE   100    13K       -      100  128
  ata_generic     3     3K       -        3  1024
       linker   109   557K       -      258  16,32,256,1024,2048,4096
        lockf    11     1K       -    27401  64
    ad_driver     2     1K       -        2  32
         temp    41   437K       -    29620  16,32,64,128,256,512,1024,2048,4096
       devbuf   455  3051K       -      477  16,32,64,128,256,512,1024,2048,4096
      ata_dma     2     1K       -        2  128
       module   215    14K       -      215  64,128
     mtx_pool     1     4K       -        1  4096
      ata_cam     2     2K       -       20  64,256,1024
      subproc   233   460K       -     3109  256,4096
         proc     2     8K       -        2  4096
      session    35     3K       -      436  64
         pgrp    42     3K       -      534  64
         cred    38    10K       -    94228  256
      uidinfo     4     2K       -      138  32,1024
       plimit    13     4K       -     2990  256
   acd_driver     1     2K       -        1  2048
    sysctltmp     0     0K       -     2857  16,32,64,128
    sysctloid  2938    90K       -     2938  16,32,64
       sysctl     0     0K       -    70024  16,32,64
         umtx   161    11K       -      161  64
     p1003.1b     1     1K       -        1  16
         SWAP     2   277K       -        2  64
       bus-sc    62    34K       -     1389  16,32,64,128,256,512,1024,2048,4096
          bus   748    35K       -     3649  16,32,64,128,1024
      devstat     8    17K       -        8  16,4096
 eventhandler    67     4K       -       67  32,64,128
      entropy  1024    64K       -     1024  64
         kobj   136   272K       -     1904  2048
         rman   179    11K       -      578  16,32,64
        USBHC     1     1K       -        1  64
         sbuf     0     0K       -      336  16,32,64,128,256,512,1024,2048,4096
       USBdev    23     9K       -       23  16,128,256,512
          USB    97    11K       -      117  16,32,64,128,512,1024
    taskqueue    15     2K       -       15  16,128
       Unitno    12     1K       -     5236  16,64
          iov     0     0K       -  2465055  16,64,128,256,512
     ioctlops     0     0K       -  4954345  16,32,64,128,256,512,1024,2048,4096
          msg     4    25K       -        4  1024,4096
          sem     4     7K       -        4  256,1024,4096
          shm     7    18K       -      313  1024
         ttys  1548   215K       -     6903  128,1024
         ptys     4     1K       -        4  128
     mbuf_tag     0     0K       -        4  32
       DEVFS1   113    29K       -      118  256
          pcb    28     5K       -     4170  16,32,64,2048
       soname    54     6K       -   263706  16,32,64,128
       biobuf   268   536K       -     1354  2048
     vfscache     1   512K       -        1
   cl_savebuf     0     0K       -     2649  32,64
     vfs_hash     1   256K       -        1
       vnodes     1     1K       -        1  128
  vnodemarker     0     0K       -     2279  512
        mount   101     4K       -      155  16,32,64,128,256
       DEVFS3   230    29K       -      233  128
          BPF    11    65K       -       12  16,64,256
  ether_multi    16     1K       -       18  16,32,64
       ifaddr    35     8K       -       35  32,256,512,2048
        ifnet     8     8K       -        8  128,1024
        clone     5    20K       -        5  4096
       arpcom     5     1K       -        5  16
           lo     1     1K       -        1  16
       DEVFS2    94     2K       -       94  16
          tun     1     1K       -        1  128
   DEVFS_RULE    36     9K       -       36  32,256
     routetbl   140    34K       -   126146  16,32,64,128,256
     in_multi     4     1K       -        4  64
     ipfw_tbl     3     1K       -        3  128
  IpFw/IpAcct     7     1K       -        7  64
    hostcache     1    20K       -        1
        DEVFS    27     1K       -       28  16,64
     syncache     1    72K       -        1
audit_evclass   150     3K       -      187  16
     savedino     0     0K       -      122  256
       dirrem     0     0K       -     5621  32
        mkdir     0     0K       -       60  32
       diradd     0     0K       -     5618  64
     freefile     0     0K       -     5524  32
     freeblks     0     0K       -     5318  256
     freefrag     0     0K       -      500  32
   allocindir     0     0K       -     1768  64
     indirdep     0     0K       -       25  32
  allocdirect     0     0K       -     7499  128
    bmsafemap     1     1K       -      246  64
       newblk     1     1K       -     9268  64,256
     inodedep     1   256K       -     5778  128
      pagedep     2    33K       -      235  64
  ufs_dirhash   255    54K       -      267  16,32,64,128,256,512,1024,2048
    ufs_mount    15    44K       -       15  256,2048,4096
      UMAHash     2     3K       -        7  256,512,1024,2048
    vm_pgdata     2    65K       -        2  64
     atkbddev     2     1K       -        2  32
    pfs_nodes    20     3K       -       20  128
    CAM queue    11     1K       -       41  16
         GEOM   111    14K       -      870  16,32,64,128,256,512,1024,2048
       isadev    19     2K       -       19  64
      io_apic     1     1K       -        1  1024
      memdesc     1     4K       -       11  32,4096
     nexusdev     5     1K       -        5  16
      CAM SIM     3     1K       -        3  128
   CAM periph     4     1K       -       10  16,32,128
      CAM XPT    27     6K       -       65  16,32,64,256,512,1024
     pci_link    16     2K       -       16  64,128
        kqemu     1     4K       -        1  4096
         ac97     2     1K       -        2  16,512
    acpi_perf     1     1K       -        1  64
       feeder   405     7K       -     3513  16,64
       acpica  2194   114K       -    51567  16,32,64,128,256,512,1024
     acpitask     0     0K       -        3  32
     ratefeed     6    61K       -     1128  64
      acpidev    64     2K       -       64  32
      acpisem    12     1K       -       12  64
        mixer     1     4K       -        1  4096
       apmdev     1     1K       -        2  64
        linux    13     1K       -      289  16,32,64
         vlan     6     1K       -        6  16,64
 netgraph_msg     0     0K       -       12  64,128,256,1024
netgraph_node     7     1K       -        7  128
netgraph_hook     4     1K       -        4  128
     netgraph     5     1K       -        5  32
netgraph_pppoe     2     1K       -        3  64,512
netgraph_sock     1     1K       -        1  64
netgraph_path     0     0K       -        5  16
          drm    55  8219K       -       77  16,32,64,128,1024,2048,4096
```


----------



## richardpl (Nov 19, 2008)

Post output of "# ps vm"
Looks like Xorg video driver have memory leaks.


----------



## TheFeaR (Nov 19, 2008)

```
[root@kirill]#ps -vm
  PID STAT      TIME  SL  RE PAGEIN   VSZ   RSS   LIM TSIZ %CPU %MEM COMMAND
 1248 R     11:51,05   0 127  19992 656876 421696     - 1512 14,3 40,6 X :0 -auth /root/.serverauth.1229 (Xorg)
 1253 R      2:59,34   0 127    296 54208 45232     -  848  0,7  4,4 enlightenment
 1219 Is     0:00,01 127 127      1  3596   780     -   20  0,0  0,1 login [pam] (login)
 1227 I      0:00,01 127 127     13  4388  1080     -  516  0,0  0,1 -bash (bash)
 1229 I+     0:00,00 127 127      0  3456   904     -  108  0,0  0,1 /bin/sh /usr/local/bin/startx
 1247 I+     0:00,00 127 127      5  4168  1044     -   12  0,0  0,1 xinit /root/.xinitrc -- -auth /root/.serverauth.1229
 1257 I      0:00,00 127 127      0  4372  1148     -   20  0,0  0,1 dbus-launch --autolaunch 7cf96b39f1ba839721cc42c5487f138
 1220 Is+    0:00,00 127 127      0  3156   648     -   20  0,0  0,1 /usr/libexec/getty Pc ttyv1
 1221 Is+    0:00,00 127 127      0  3156   648     -   20  0,0  0,1 /usr/libexec/getty Pc ttyv2
 1222 Is+    0:00,00 127 127      0  3156   648     -   20  0,0  0,1 /usr/libexec/getty Pc ttyv3
 1223 Is+    0:00,00 127 127      0  3156   648     -   20  0,0  0,1 /usr/libexec/getty Pc ttyv4
 1224 Is+    0:00,00 127 127      0  3156   648     -   20  0,0  0,1 /usr/libexec/getty Pc ttyv5
 1225 Is+    0:00,00 127 127      0  3156   648     -   20  0,0  0,1 /usr/libexec/getty Pc ttyv6
 1226 Is+    0:00,00 127 127      0  3156   648     -   20  0,0  0,1 /usr/libexec/getty Pc ttyv7
 2775 Is     0:00,01  45 127      0  4388  1848     -  516  0,0  0,2 bash
 2783 I+     0:00,87  40 127     22  6540  3420     -  108  0,0  0,3 ssh r1-acc
 3781 Ss     0:00,01   0  39      0  4388  1876     -  516  0,0  0,2 bash
 3797 R+     0:00,00 127   0      0  3220   988     -   24  0,0  0,1 ps -vm
```


----------



## richardpl (Nov 19, 2008)

And output of "dmesg |grep agp"


----------



## TheFeaR (Nov 19, 2008)

dmesg |grep agp

empty output.


```
vgapci0: <VGA-compatible display> port 0xa000-0xa0ff mem 0xb0000000-0xbfffffff,0xc0030000-0xc003ffff irq 16 at device 0.0 on pci1
vgapci1: <VGA-compatible display> mem 0xc0020000-0xc002ffff at device 0.1 on pci1
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
drm0: <ATI Radeon RV410 X700 Pro> on vgapci0
info: [drm] Initialized radeon 1.25.0 20060524
info: [drm] Setting GART location based on new memory map
info: [drm] Loading R300 Microcode
info: [drm] writeback test succeeded in 1 usecs
drm0: [ITHREAD]
```


```
[root@kirill]#pciconf -lv|grep -A3 vga
vgapci0@pci0:1:0:0:     class=0x030000 card=0x2800174b chip=0x5e4b1002 rev=0x00 hdr=0x00
    vendor     = 'ATI Technologies Inc'
    device     = 'Radeon X700 Series'
    class      = display
--
vgapci1@pci0:1:0:1:     class=0x038000 card=0x2801174b chip=0x5e6b1002 rev=0x00 hdr=0x00
    vendor     = 'ATI Technologies Inc'
    device     = 'Radeon X700 Series - Secondary'
    class      = display
```


----------



## richardpl (Nov 19, 2008)

Change *Option "RenderAccel"* to *"false"*.
Explore radeonhd man page.
Try radeonhd-devel driver instead, which have dri completely disabled.

Maybe posting /var/log/Xorg.*.log.


----------



## TheFeaR (Nov 19, 2008)

thx. I disable render acceleration. Will see what happen!


----------



## TheFeaR (Nov 21, 2008)

nop.. it does not help.

4331 root          1  96    0   812M   355M select  23:04  8.54% Xorg


will try devel version of driver. Can you say HOW you determine that the problem is in driver?


----------



## TheFeaR (Nov 27, 2008)

Devel version of driver is does not help too.

14413 root          1  96    0   825M   441M RUN     18:00  0.00% Xorg


----------



## richardpl (Nov 27, 2008)

Try asking on freebsd-x11 mailing list.


----------

