Bug 469103

Summary: Plasmashell leak memory after disabling second monitor from Nvidia Settings
Product: [Plasma] plasmashell Reporter: omano <omano>
Component: generic-performanceAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED DUPLICATE    
Severity: major CC: nate
Priority: NOR    
Version: 5.27.4   
Target Milestone: 1.0   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Logging of Plasmashell monitoring

Description omano 2023-04-28 13:39:08 UTC
Created attachment 158516 [details]
Logging of Plasmashell monitoring

SUMMARY
***
After I enable, and then disable my second monitor with the Nvidia driver, Plasmashell leaks memory rapidly untill the point the system runs out of memory. The issue is ongoing since multiple months/updates.
***


STEPS TO REPRODUCE
1. Enable the second monitor in Nvidia Panel
2. Disable the second monitor in Nvidia Panel after a while
3. See Plasmashell increasing its memory usage by a lot constantly

OBSERVED RESULT
Plasmashell has memory leak

EXPECTED RESULT
Plasmashell doesn't leak memory

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Linux 6.1.25
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9

ADDITIONAL INFORMATION
I made a script that I run every minutes with CRON to monitor Plasmashell PID, memory usage, cpu usage, and the second monitor, you can see as soon as I disable my second monitor, memory usage is increasing by a lot and it never stops. I attached the log it produces for you to have a look.
You can also see that the CPU usage by Plasmashell is to the roof too at this point (I only added that to the end when I was writing this issue so it appears only at the end).
Plasmashell PID also changes after I disable the second monitor.

It seems trying to reproduce it quickly from cold boot and enabling/disabling the second monitor after a couple minutes doesn't make the memory leak as quick as it is in the attached log.

In the attached log, the second monitor is enabled at "ven. 28 avril 2023 06:20:01 CEST" and is disabled at "ven. 28 avril 2023 14:40:01 CEST"
Comment 1 omano 2023-04-28 16:18:27 UTC
Additional info (inxi -Fazy):

```
System:
  Kernel: 6.1.25-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.2.1
    parameters: BOOT_IMAGE=/boot/vmlinuz-6.1-x86_64
    root=UUID=6a81f472-9ea9-40f8-85f6-7925c4bbe742 ro quiet splash
    udev.log_priority=3 sysrq_always_enabled=1 amd_pstate=passive
    amd_pstate.shared_mem=1 mitigations=off nowatchdog delayacct
  Desktop: KDE Plasma v: 5.27.4 tk: Qt v: 5.15.9 wm: kwin_x11 vt: 1 dm: SDDM
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Desktop System: Gigabyte product: B450M DS3H v: N/A
    serial: <superuser required>
  Mobo: Gigabyte model: B450M DS3H-CF serial: <superuser required>
    UEFI: American Megatrends LLC. v: F64a date: 02/09/2023
CPU:
  Info: model: AMD Ryzen 5 3600 bits: 64 type: MT MCP arch: Zen 2 gen: 3
    level: v3 note: check built: 2020-22 process: TSMC n7 (7nm) family: 0x17 (23)
    model-id: 0x71 (113) stepping: 0 microcode: 0x8701030
  Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
    L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 3 MiB desc: 6x512 KiB L3: 32 MiB
    desc: 2x16 MiB
  Speed (MHz): avg: 588 high: 909 min/max: 550/4426 boost: enabled scaling:
    driver: amd-pstate governor: schedutil cores: 1: 550 2: 550 3: 627 4: 550
    5: 550 6: 550 7: 551 8: 550 9: 550 10: 909 11: 579 12: 550 bogomips: 86279
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
  Vulnerabilities:
  Type: itlb_multihit status: Not affected
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: mmio_stale_data status: Not affected
  Type: retbleed status: Vulnerable
  Type: spec_store_bypass status: Vulnerable
  Type: spectre_v1 status: Vulnerable: __user pointer sanitization and
    usercopy barriers only; no swapgs barriers
  Type: spectre_v2 status: Vulnerable, IBPB: disabled, STIBP: disabled,
    PBRSB-eIBRS: Not affected
  Type: srbds status: Not affected
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: NVIDIA GP106 [GeForce GTX 1060 6GB] vendor: eVga.com.
    driver: nvidia v: 530.41.03 alternate: nouveau,nvidia_drm non-free: 530.xx+
    status: current (as of 2023-03) arch: Pascal code: GP10x process: TSMC 16nm
    built: 2016-21 pcie: gen: 3 speed: 8 GT/s lanes: 16 bus-ID: 07:00.0
    chip-ID: 10de:1c03 class-ID: 0300
  Display: x11 server: X.Org v: 21.1.8 with: Xwayland v: 23.1.1
    compositor: kwin_x11 driver: X: loaded: nvidia gpu: nvidia display-ID: :0
    screens: 1
  Screen-1: 0 s-res: 1920x1200 s-dpi: 93 s-size: 524x320mm (20.63x12.60")
    s-diag: 614mm (24.17")
  Monitor-1: DP-0 pos: primary res: 1920x1200 dpi: 94
    size: 518x324mm (20.39x12.76") diag: 611mm (24.05") modes: N/A
  Monitor-2: HDMI-0 size-res: N/A modes: N/A
  API: OpenGL v: 4.6.0 NVIDIA 530.41.03 renderer: NVIDIA GeForce GTX 1060
    6GB/PCIe/SSE2 direct-render: Yes
Audio:
  Device-1: NVIDIA GP106 High Definition Audio vendor: eVga.com.
    driver: snd_hda_intel v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16
    bus-ID: 07:00.1 chip-ID: 10de:10f1 class-ID: 0403
  Device-2: AMD Starship/Matisse HD Audio vendor: Gigabyte
    driver: snd_hda_intel v: kernel pcie: gen: 4 speed: 16 GT/s lanes: 16
    bus-ID: 09:00.4 chip-ID: 1022:1487 class-ID: 0403
  API: ALSA v: k6.1.25-1-MANJARO status: kernel-api with: aoss
    type: oss-emulator tools: alsamixer,amixer
  Server-1: JACK v: 1.9.22 status: off tools: N/A
  Server-2: PipeWire v: 0.3.70 status: off with: pipewire-media-session
    status: off tools: pw-cat,pw-cli
  Server-3: PulseAudio v: 16.1 status: active tools: pacat,pactl,pavucontrol
Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: Gigabyte driver: r8169 v: kernel pcie: gen: 1 speed: 2.5 GT/s
    lanes: 1 port: f000 bus-ID: 05:00.0 chip-ID: 10ec:8168 class-ID: 0200
  IF: enp5s0 state: up speed: 1000 Mbps duplex: full mac: <filter>
Drives:
  Local Storage: total: 2.03 TiB used: 1.05 TiB (51.6%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Crucial model: CT1000P1SSD8
    size: 931.51 GiB block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s
    lanes: 4 type: SSD serial: <filter> rev: P3CR020 temp: 46.9 C scheme: GPT
  ID-2: /dev/sda maj-min: 8:0 vendor: SanDisk model: SSD PLUS 480GB
    size: 447.14 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    type: SSD serial: <filter> rev: 00RL scheme: GPT
  ID-3: /dev/sdb maj-min: 8:16 vendor: Western Digital
    model: WD5001AALS-00E3A0 size: 465.76 GiB block-size: physical: 512 B
    logical: 512 B speed: 3.0 Gb/s type: N/A serial: <filter> rev: 1D05
    scheme: MBR
  ID-4: /dev/sdc maj-min: 8:32 vendor: SanDisk model: SDSSDHP256G
    size: 238.47 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    type: SSD serial: <filter> rev: 6RL scheme: GPT
Partition:
  ID-1: / raw-size: 931.22 GiB size: 915.53 GiB (98.32%)
    used: 801.42 GiB (87.5%) fs: ext4 dev: /dev/nvme0n1p2 maj-min: 259:2
  ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
    used: 9.1 MiB (3.0%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
Swap:
  Kernel: swappiness: 10 (default 60) cache-pressure: 75 (default 100)
  ID-1: swap-1 type: file size: 16 GiB used: 0 KiB (0.0%) priority: -2
    file: /swapfile
Sensors:
  System Temperatures: cpu: 40.5 C mobo: 33.0 C gpu: nvidia temp: 55 C
  Fan Speeds (RPM): N/A gpu: nvidia fan: 12%
Info:
  Processes: 318 Uptime: 3h 3m wakeups: 0 Memory: 15.54 GiB
  used: 4.59 GiB (29.5%) Init: systemd v: 253 default: graphical
  tool: systemctl Compilers: gcc: 12.2.1 clang: 15.0.7 Packages: pm: pacman
  pkgs: 1763 libs: 463 tools: octopi,pamac,yay Shell: Bash v: 5.1.16
  running-in: konsole inxi: 3.3.26
```
Comment 2 Nate Graham 2023-04-28 20:47:44 UTC

*** This bug has been marked as a duplicate of bug 466362 ***