NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.11k stars 14.15k forks source link

Xserver memory leak #26567

Closed ikervagyok closed 5 years ago

ikervagyok commented 7 years ago

Issue description

Noticed this a few times, but never had time to look into it. Maybe some hints can be given, what to look for next time this happens.

Steps to reproduce

Use Nixos desktop as usual (in my case with xmonad) and wait. after a few days of usage, even if i close all apps, X will consume more memory with every passing day.

Hardware:

$ lspci
00:00.0 Host bridge: Intel Corporation Skylake Host Bridge/DRAM Registers (rev 07)
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
00:14.0 USB controller: Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller (rev 31)
00:16.0 Communication controller: Intel Corporation Sunrise Point-H CSME HECI #1 (rev 31)
00:16.3 Serial controller: Intel Corporation Sunrise Point-H KT Redirection (rev 31)
00:17.0 SATA controller: Intel Corporation Sunrise Point-H SATA controller [AHCI mode] (rev 31)
00:1f.0 ISA bridge: Intel Corporation Sunrise Point-H LPC Controller (rev 31)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-H PMC (rev 31)
00:1f.3 Audio device: Intel Corporation Sunrise Point-H HD Audio (rev 31)
00:1f.4 SMBus: Intel Corporation Sunrise Point-H SMBus (rev 31)
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (2) I219-LM (rev 31)

all possibly relevant parts of my config:

{ config, pkgs, ... }:

{
  boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" ];
  boot.extraModulePackages = [ ];
  boot.initrd.availableKernelModules = [ "ahci" "i8042" ];
  boot.kernelModules = [ "msr" "kvm-intel" "virtio" "tun" "cpufreq_stats" "radeon" ];
  boot.kernelPackages = pkgs.linuxPackages_latest;

  boot.kernelParams = [
    "video.use_native_backlight=1"
    "acpi_backlight=vendor"
    "zswap.enabled=1"
    "zswap.max_pool_percent=15"
    "zswap.compressor=lz4"
    "zswap.zpool=zsmalloc"
    "zcache"
    "intel_iommu=on"
  ];

  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.systemd-boot.enable = true;
  boot.loader.timeout = 2;

  boot.tmpOnTmpfs = true;

  gnu = false;

  hardware.cpu.intel.updateMicrocode = true;
  hardware.enableAllFirmware = true;

  hardware.opengl.s3tcSupport = true;
  hardware.opengl.driSupport = true;
  hardware.opengl.driSupport32Bit = true;

  hardware.pulseaudio.enable = true;
  hardware.pulseaudio.package = pkgs.pulseaudioFull;
  hardware.pulseaudio.support32Bit = true;

  i18n = {
      consoleKeyMap = "us";
      defaultLocale = "en_US.UTF-8";
  };

  networking.firewall = {
    allowedTCPPorts = [ 22 80 443 8080 ];
    allowedUDPPorts = [ 22 ];
    checkReversePath = true;
    enable = false;
  };

  nixpkgs.config.allowUnfree = true;

  powerManagement.enable = true;
  powerManagement.cpuFreqGovernor = "powersave";

  services.dbus.enable = true;

  services.timesyncd.enable = true;

  services.redshift.brightness.night = "0.8";
  services.redshift.enable = true;
  services.redshift.latitude = "48.196045";
  services.redshift.longitude = "16.364028";

  services.xserver.desktopManager.gnome3.enable = true;
  services.xserver.displayManager.lightdm.enable = true;
  services.xserver.enable = true;
  services.xserver.layout = "us"; 
  services.xserver.libinput.enable = true;
  services.xserver.videoDrivers = [ "intel" ];
  services.xserver.desktopManager.xterm.enable = false;
  services.xserver.windowManager.default = "xmonad";
  services.xserver.windowManager.xmonad.enable = true;
  services.xserver.windowManager.xmonad.enableContribAndExtras = true;
  services.xserver.xkbOptions = "eurosign:e";

  system.autoUpgrade.channel = "https://nixos.org/channels/nixos-unstable";
  system.autoUpgrade.enable = true;

  time.hardwareClockInLocalTime = false;
  time.timeZone = "Europe/Vienna";

Technical details

0xABAB commented 7 years ago

@ikervagyok In top you should be able to figure out the set of processes with high memory. There are cases where the X server has no leak, but the clients create a leak due to bad usage of the X server.

https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/1272338 is a case of a video driver bug.

For all the user space memory applications, you can use valgrind.

For possible driver issues, you can do https://unix.stackexchange.com/questions/209284/kernel-memory-leak-detection.

ikervagyok commented 7 years ago

@0xABAB: this is what htop shows me - just firefox and thunderbird running for the weekend, on xmonad with xmobar and xcompmgr and lightdm as a greeter. Will look into the posts as soon as i can, thank you!

htop

aij commented 6 years ago

I also have xorg seemingly leaking memory over time.

There are cases where the X server has no leak, but the clients create a leak due to bad usage of the X server.

@0xABAB Shouldn't that show up in xrestop?

xrestop - Display: localhost:0
          Monitoring 24 clients. XErrors: 0
          Pixmaps:   43445K total, Other:      88K total, All:   43533K total

res-base Wins  GCs Fnts Pxms Misc   Pxm mem  Other   Total   PID Identifier    
2a00000     3   68    0    5  137    31796K      4K  31801K   ?   <unknown>
0c00000     9   26    0    3   10     4440K      1K   4441K 24831 trayer
0400000     0    2    0    2    7     4342K    216B   4343K   ?   <unknown>
2000000    12   14    1    4   73     2475K      3K   2478K  6475 -emacs-wrapped
1c00000    14   30    1   14   51      389K      3K    392K 27005 Pidgin
1600000     3    5    9    1   32      628B      9K     10K 26670
1400000     3    5    6    1   36      320B      7K      7K 25605 urxvt
1800000     3    5    6    1   35      328B      7K      7K 26684
0e00000     1    1    0    0  307        0B      7K      7K   ?   LG3D
1000000     1    1    7    0    1        0B      7K      7K 24873 xmobar
1a00000     3    5    5    1   24      316B      5K      6K 26698
0000000     1    0    2    0  171        0B      6K      6K   ?   <unknown>
2600000     9    4    1    0  198        9B      5K      5K 25753 google-chrome-beta
1e00000     3    5    5    0    8        0B      5K      5K 27658
0a00000     2    1    3    0   84        0B      5K      5K   ?   screensaver
2400000     3    5    3    0    8        0B      3K      3K 14428 urxvt
2200000     3    5    3    0    8        0B      3K      3K 14409 urxvt
2800000     5    2    1    0   33        0B      1K      1K   ?   Chromium clipboard
1200000     0    1    0    0    2        0B     72B     72B   ?   <unknown>
2e00000     1    1    0    0    0        0B     48B     48B   ?   xrestop
2c00000     1    1    0    0    0        0B     48B     48B   ?   <unknown>
0600000     1    1    0    0    0        0B     48B     48B   ?   <unknown>
0800000     0    1    0    0    0        0B     24B     24B   ?   <unknown>
0200000     0    1    0    0    0        0B     24B     24B   ?   <unknown>

That's less than 44MB though, while top shows nearly 8 GB.

top - 14:27:51 up 64 days,  3:24,  2 users,  load average: 0.48, 0.61, 0.78
Tasks: 367 total,   1 running, 366 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.3 us,  0.7 sy,  0.0 ni, 98.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  32064.0 total,   8109.0 free,  22516.3 used,   1438.7 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   8562.1 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND          
23615 root      20   0 8685812   7.8g  51624 S   2.7  24.8 678:33.18 X                
 7524 aij       20   0   13.9g   4.4g  22668 S   1.0  14.1  15:04.13 java             
27646 aij       20   0   13.9g 720656  45904 S   1.0   2.2   0:30.03 java             
31664 aij       20   0 1468252 539008  69680 S   1.0   1.6  44:45.69 chrome           
 5537 aij       20   0 3369348 462884  58644 S   0.0   1.4   8:36.79 chrome           
25753 aij       20   0 1543684 328716 103200 S   5.0   1.0 790:56.47 chrome           
27208 aij       20   0 1579520 299268  57092 S   0.0   0.9  12:52.44 chrome           
 8629 aij       20   0 1459332 278516  15632 S   0.0   0.8   0:20.82 node             
 8831 aij       20   0   26.3g 250492  37684 S   0.0   0.8   0:02.71 flow             
19106 aij       20   0 1255768 214776  75000 S   0.7   0.7  20:31.84 chrome           
  301 aij       20   0 1172452 213620  61452 S   0.0   0.7   2:35.13 chrome           
25910 aij       20   0  845888 199212  65788 S   1.3   0.6  60:35.91 chrome           
10009 aij       20   0 1144500 169556  58840 S   0.3   0.5   2:06.98 chrome           

Don't know if it's related, but I am also using xmonad and xmobar, though without xcompmgr, and I also have Intel HD Graphics:

00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)
ikervagyok commented 5 years ago

@aij i don't use this configuration anymore, so i'm closing this issue.