Bug 238698

Summary: x11/nvidia-driver: memory leak
Product: Ports & Packages Reporter: Ivan Rozhuk <rozhuk.im>
Component: Individual Port(s)Assignee: Alexey Dokuchaev <danfe>
Status: Closed Not Enough Information    
Severity: Affects Some People CC: bsd, grahamperrin, pi, rozhuk.im
Priority: --- Flags: bugzilla: maintainer-feedback? (danfe)
Version: Latest   
Hardware: Any   
OS: Any   

Description Ivan Rozhuk 2019-06-18 21:35:18 UTC
Looks like mem leak in x11/nvidia-driver, x11/nvidia-driver-340.
Then slim launch xorg it consume 6 gb (top: SIZE) with x11/nvidia-driver and 3 gb with x11/nvidia-driver-340.
On same config with amdgpu and scfb 100-300mb.

FreeBSD rimwks 12.0-STABLE FreeBSD 12.0-STABLE #0 r346795M: Sun Apr 28 01:43:38 MSK 2019     root@rimwks:/usr/obj/usr/src/amd64.amd64/sys/RIM_WKS  amd64
xorg-server-1.19.6_11,1

I already try with generic kernel and with empty device settings:
Section "Device"
    Identifier  "Card0"
    Driver      "nvidia"
EndSection


Now on my desktop:
nvidia-smi
Wed Jun 19 00:31:39 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.87                 Driver Version: 390.87                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GT 1030     Off  | 00000000:2D:00.0  On |                  N/A |
| 32%   43C    P0    N/A /  30W |    939MiB /  1992MiB |      4%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1444      G   /usr/local/bin/mpv                            13MiB |
|    0     37232      G   /usr/local/lib/firefox/firefox                 7MiB |
|    0     48627      G   /usr/local/bin/mpv                            15MiB |
|    0     51747      G   /usr/local/bin/mpv                            15MiB |
|    0     66792      G   /usr/local/lib/firefox/firefox                 1MiB |
|    0     77564      G   /usr/local/bin/Xorg                          847MiB |
|    0     95186      G   /usr/local/bin/mpv                            13MiB |
+-----------------------------------------------------------------------------+


last pid: 29609;  load averages:  0.82,  0.76,  0.75                                                                                                                up 37+22:47:24  00:28:31
153 processes: 1 running, 151 sleeping, 1 zombie
CPU:  2.1% user,  0.0% nice,  1.1% system,  0.0% interrupt, 96.8% idle
Mem: 1962M Active, 7144M Inact, 5923M Laundry, 12G Wired, 1550M Buf, 4495M Free
Swap: 64G Total, 20G Used, 44G Free, 31% Inuse, 156K In

  PID USERNAME    THR PRI NICE   SIZE    RES STATE    C   TIME    WCPU COMMAND
77564 root          2  20  -15    25G   463M select  15  17.2H   1.87% Xorg
Comment 1 Alexey Dokuchaev freebsd_committer freebsd_triage 2020-01-26 13:34:27 UTC
I'm not entirely convinced that this particular problem should be addressed by the FreeBSD hackers rather than nVidia guys themselves.  Did you try to report it on their official forum?

  https://devtalk.nvidia.com/default/board/97/freebsd/
Comment 2 Alexey Dokuchaev freebsd_committer freebsd_triage 2021-05-13 03:45:49 UTC
(In reply to rozhuk.im from comment #0)
> Then slim launch xorg it consume 6 GB with x11/nvidia-driver and 3 GB with
> x11/nvidia-driver-340.
Do you still experience this with the latest drivers' versions?  Also note that just the difference in the initial allocated memory does not necessarily implies that memory is/will be leaking.  Did you observe how these numbers change with time?
Comment 3 Alexey Dokuchaev freebsd_committer freebsd_triage 2022-10-19 09:10:26 UTC
Due to closed-source, binary-only nature of nVidia drivers, we can't too much here I'm afraid.  Please reopen if you can get and provide evidence that the actual leak, may it be caused by the driver, happens in the open-source parts of the graphics stack where we could fix them.  As of right now, this PR is not really actionable.