Skip to content

xwayland has a VRAM leak on nvidia system when resizing Emacs window

Description:

When using Emacs (which doesn't support wayland) under Xwayland, resizing the window up and down will cause the VRAM usage (as noted by nvidia-smi) to go up to 2.4gb.

Additional info:

  • package version(s): 23.2.3-1
  • config and/or log files:
kernel version: 6.6.8
mesa version: 1:23.3.1-1
nvidia-dkms: 545.29.06-1
emacs-nativecomp: 29.1-4

Steps to reproduce:

  1. Start a Plasma (wayland) session or hyprland
  2. Install emacs-nativecomp (I have 29.1-4)
  3. Open emacs --no-init-file
  4. In a terminal, run watch -n1 nvidia-smi
  5. Resize the window a few times
  6. Close emacs
  7. Notice the nvidia-smi output is really high:
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.29.06              Driver Version: 545.29.06    CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 4090        Off | 00000000:06:00.0  On |                  Off |
|  0%   34C    P5              41W / 450W |   3435MiB / 24564MiB |      2%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      5104      G   Hyprland                                    473MiB |
|    0   N/A  N/A      5175      G   /usr/lib/firefox/firefox                    403MiB |
|    0   N/A  N/A     11026      G   Xwayland                                   2465MiB |
+---------------------------------------------------------------------------------------+

Let me know how else I can debug this. As far as I can tell, I don't see anything related to Xwayland in the compositor logs (which I think is in journalctl -b 0, also checked journalctl --user -b 0, nor is there anything interesting in the kernel logs.

And this only happens for emacs, it doesn't appear to happen for apps like xterm.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information