hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
19.51k stars 818 forks source link

Possible memory usage issue with KiCAD #6885

Closed Isoheptane closed 1 month ago

Isoheptane commented 1 month ago

Regression?

Yes

System Info and Version

System/Version info ```sh Hyprland, built from branch at commit 918d8340afd652b011b937d29d5eea0be08467f5 (flake.lock: update). Date: Tue Jun 25 12:06:02 2024 Tag: v0.41.2, commits: 4886 flags: (if any) System Information: System name: Linux Node name: cascade-ws Release: 6.9.8-zen1-1-zen Version: #1 ZEN SMP PREEMPT_DYNAMIC Fri, 05 Jul 2024 22:11:01 +0000 GPU information: 26:00.0 VGA compatible controller [0300]: NVIDIA Corporation TU106 [GeForce RTX 2060 SUPER] [10de:1f06] (rev a1) (prog-if 00 [VGA controller]) os-release: NAME="Arch Linux" PRETTY_NAME="Arch Linux" ID=arch BUILD_ID=rolling ANSI_COLOR="38;2;23;147;209" HOME_URL="https://archlinux.org/" DOCUMENTATION_URL="https://wiki.archlinux.org/" SUPPORT_URL="https://bbs.archlinux.org/" BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues" PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/" LOGO=archlinux-logo plugins: ======Config-Start====== Config File: /home/cascade/.config/hypr/hyprland.conf: Read Succeeded # See https://wiki.hyprland.org/Configuring/Monitors/ monitor = HDMI-A-2, highrr, 0x0, 1.0 monitor = Unknown-1, highrr, -1920x1080, 1.0 # monitor = , preferred, auto, 1.0 xwayland { force_zero_scaling = true } # See https://wiki.hyprland.org/Configuring/Keywords/ for more # Execute your favorite apps at launch # exec-once = waybar & hyprpaper & firefox # Source a file (multi-file configs) # source = ~/.config/hypr/myColors.conf # Some default env vars. env = XCURSOR_SIZE,32 # For all categories, see https://wiki.hyprland.org/Configuring/Variables/ input { kb_layout = us kb_variant = kb_model = follow_mouse = 1 touchpad { natural_scroll = yes } tablet { region_position = 416 0 region_size = 1728 1080 } sensitivity = 0 # -1.0 - 1.0, 0 means no modification. accel_profile = flat } general { # See https://wiki.hyprland.org/Configuring/Variables/ for more gaps_in = 4 gaps_out = 8 border_size = 1 col.active_border = rgba(dbe3c8ff) col.inactive_border = rgba(2222227f) allow_tearing = true layout = dwindle } env = WLR_DRM_NO_ATOMIC,1 windowrulev2 = immediate, class:^(cs2)$ decoration { # See https://wiki.hyprland.org/Configuring/Variables/ for more rounding = 20 drop_shadow = true col.shadow = rgba(0000005f) col.shadow_inactive = rgba(0000003f) shadow_range = 25 blur { enabled = true size = 2 passes = 2 contrast = 1.2 } } animations { enabled = true # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more bezier = myBezier, 0.05, 0.9, 0.1, 1.05 animation = windowsMove, 1, 7, myBezier animation = windowsIn, 1, 3, default, popin 90% animation = windowsOut, 1, 2, default, popin 95% animation = border, 1, 3, default animation = fade, 1, 3, default animation = workspaces, 1, 5, default } dwindle { # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below preserve_split = true # you probably want this split_width_multiplier = 1.4 } misc { #force_hypr_chan = true mouse_move_enables_dpms = true key_press_enables_dpms = true } # Layer Rules layerrule = blur, notifications layerrule = ignorezero, notifications layerrule = blur, launcher layerrule = ignorezero, launcher # Window Rules windowrulev2 = float,class:(QQ) # QQ Popups windowrulev2 = float,title:(Volume Control) # Volume Control windowrulev2 = float,class:(steam) # Steam Popups windowrulev2 = float,title:(Qt5 Configuration Tool) # Qt5 windowrulev2 = float,title:(Qt6 Configuration Tool) # Qt6 windowrulev2 = float,title:(Fcitx Configuration) # Fcitx Config windowrulev2 = float,class:(org.gnome.Nautilus) # Nautilus Popups windowrulev2 = float,class:(firefox),title:(Library) # Firefox Popups windowrulev2 = float,class:(vlc) # VLC Popups windowrulev2 = float,class:(qemu.*) # QEMU windowrulev2 = float,class:(org.telegram.desktop),title:(Media viewer) windowrulev2 = opacity 1.0,class:(cloudmusic.exe),title:(^$) # windowrulev2 = opacity 0,class:^(fcitx)$ # Fcitx windowrulev2 = immediate, class:^(Celeste.bin.x86_64)$ windowrulev2 = immediate, class:^(KSP.x86_64)$ # pinned window windowrulev2 = bordercolor rgb(598da8) rgb(598da8), pinned:1 # Variables $proxy_socks5 = socks5://localhost:1080 $proxy_http = http://localhost:1081 # See https://wiki.hyprland.org/Configuring/Keywords/ for more $mainMod = SUPER # Function Key bindings bind = ,xf86audiomute, exec, pactl -- set-sink-mute @DEFAULT_SINK@ toggle bind = ,xf86audiolowervolume, exec, pactl -- set-sink-volume @DEFAULT_SINK@ -5% bind = ,xf86audioraisevolume, exec, pactl -- set-sink-volume @DEFAULT_SINK@ +5% bind = ,xf86audiomicmute, exec, pactl -- set-source-mute @DEFAULT_SOURCE@ toggle bind = ,xf86monbrightnessdown, exec, blight -d backlight/amdgpu_bl1 set -25.5 bind = ,xf86monbrightnessup, exec, blight -d backlight/amdgpu_bl1 set +25.5 # Hyprland hotkeys bind = $mainMod, C, killactive, bind = $mainMod, T, exec, alacritty bind = $mainMod, M, exit, bind = $mainMod, E, exec, nautilus --new-window bind = $mainMod, V, togglefloating, bind = $mainMod, R, exec, tofi-drun | xargs hyprctl dispatch exec -- ALL_PROXY=$proxy bind = $mainMod, P, pseudo, # dwindle bind = $mainMod, J, togglesplit, # dwindle bind = $mainMod, F, fullscreen bind = $mainMod, U, bringactivetotop bind = $mainMod, O, exec, dpms, on bind = $mainMod, Z, pin # Hyprland some reload bind = $mainMod CTRL ALT, R, exec, killall waybar; waybar # Screenshot bind = $mainMod SHIFT, S, exec, grim -g "$(slurp)" - | wl-copy bind = $mainMod SHIFT, W, exec, grim -g "$(hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')" - | wl-copy bind = ,print , exec, grim - | wl-copy # OBS bind = $mainMod, HOME, exec, obs-cli recording start --host 127.0.0.1 --port 50000 bind = $mainMod, END, exec, obs-cli recording stop --host 127.0.0.1 --port 50000 # Move focus with mainMod + arrow keys bind = $mainMod, left, movefocus, l bind = $mainMod, right, movefocus, r bind = $mainMod, up, movefocus, u bind = $mainMod, down, movefocus, d $switch_script = /home/cascade/.config/hypr/switch_workspace.sh # Switch workspaces with mainMod + [0-9] bind = $mainMod, 1, exec, $switch_script switch 1 bind = $mainMod, 2, exec, $switch_script switch 2 bind = $mainMod, 3, exec, $switch_script switch 3 bind = $mainMod, 4, exec, $switch_script switch 4 bind = $mainMod, 5, exec, $switch_script switch 5 bind = $mainMod, 6, exec, $switch_script switch 6 bind = $mainMod, 7, exec, $switch_script switch 7 bind = $mainMod, 8, exec, $switch_script switch 8 bind = $mainMod, 9, exec, $switch_script switch 9 bind = $mainMod, 0, exec, $switch_script switch 10 bind = $mainMod, X, togglespecialworkspace # Move active window to a workspace with mainMod + SHIFT + [0-9] bind = $mainMod SHIFT, 1, exec, $switch_script move 1 bind = $mainMod SHIFT, 2, exec, $switch_script move 2 bind = $mainMod SHIFT, 3, exec, $switch_script move 3 bind = $mainMod SHIFT, 4, exec, $switch_script move 4 bind = $mainMod SHIFT, 5, exec, $switch_script move 5 bind = $mainMod SHIFT, 6, exec, $switch_script move 6 bind = $mainMod SHIFT, 7, exec, $switch_script move 7 bind = $mainMod SHIFT, 8, exec, $switch_script move 8 bind = $mainMod SHIFT, 9, exec, $switch_script move 9 bind = $mainMod SHIFT, 0, exec, $switch_script move 10 bind = $mainMod SHIFT, X, movetoworkspace, special bind = $mainMod SHIFT, comma, movecurrentworkspacetomonitor, l bind = $mainMod SHIFT, period, movecurrentworkspacetomonitor, r workspace = r[1-5],monitor:ID,HDMI-A-2 workspace = r[6-10],monitor:ID,Unknown-1 # Scroll through existing workspaces with mainMod + scroll bind = $mainMod, mouse_down, workspace, e+1 bind = $mainMod, mouse_up, workspace, e-1 # Move/resize windows with mainMod + LMB/RMB and dragging bindm = $mainMod, mouse:272, movewindow bindm = $mainMod, mouse:273, resizewindow # Input Methods env = XMODIFIERS, @im=fcitx # This line is removed since it causes GTK applications crash (if without Wayland support) # env = GTK_IM_MODULE, wayland # env = QT_IM_MODULE, wayland env = SDL_IM_MODULE, fcitx # SDL wayland # This is deprecated since many clients does not support wayland # env = SDL_VIDEODRIVER, "wayland,x11" # NVIDIA Fix env = LIBVA_DRIVER_NAME, nvidia env = XDG_SESSION_TYPE, wayland env = GBM_BACKEND, nvidia-drm env = __GLX_VENDOR_LIBRARY_NAME, nvidia env = WLR_NO_HARDWARE_CURSORS, 1 # Other Environment env = QT_QPA_PLATFORMTHEME, qt5ct # Proxy env = ALL_PROXY, $proxy_socks5 env = HTTP_PROXY, $proxy_http env = HTTPS_PROXY, $proxy_http env = all_proxy, $proxy_socks5 env = http_proxy, $proxy_http env = https_proxy, $proxy_http env = NO_PROXY, 127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 # Auto start exec-once = hyprpaper exec-once = waybar exec-once = fcitx5 # exec-once = swayidle timeout 300 'hyprctl dispatcher dpms off' exec-once = dbus-update-activation-environment --systemd --all ======Config-End======== ``` Content of switch script `/home/cascade/.config/hypr/switch_workspace.sh` ```bash #!/bin/bash operation=$1 workspace=$2 monitor_id=$(hyprctl activeworkspace | grep "monitorID" | awk '{print $2}') workspace_id=$(($monitor_id * 10 + $workspace)) echo "Final Operation: $operation to $workspace_id" if [[ $operation == "switch" ]]; then # hyprctl dispatch moveworkspacetomonitor $workspace_id $monitor_id; hyprctl dispatch workspace $workspace_id; fi if [[ $operation == "move" ]]; then # hyprctl dispatch moveworkspacetomonitor $workspace_id $monitor_id; hyprctl dispatch movetoworkspace $workspace_id; fi ```

Description

When selecting which symbol to add in KiCAD eeschema (KiCAD 8.0.3), RAM/VRAM usage of Hyprland rapidly rises and doesn't drop. Each time you select a new symbol, RAM usage of Hyprland rises for about 10 MB.

After fully closing KiCAD, memory usage drops to normal level.

It's also reported that KiCAD 8.0.3 have a possible memory leakage issue, but when I was reproducing this issue, memory usage of KiCAD didn't rise.

How to reproduce

Crash reports, logs, images, videos

No response

Isoheptane commented 1 month ago

I tried reproducing this problem on sway and older versions of Hyprland. This issue can not be reproduced on sway and Hyprland v0.39.1. Trying to bisect now.

Isoheptane commented 1 month ago
git bisect start
# status: waiting for both good and bad commits
# bad: [ea2501d4556f84d3de86a4ae2f4b22a474555b9f] props: bump version to 0.41.0
git bisect bad ea2501d4556f84d3de86a4ae2f4b22a474555b9f
# status: waiting for good commit(s), bad commit known
# good: [db5d39a66f1285f78321d953eac398feaedfc63d] meson: add more xcb-* dependencies after addd3e7f1aeb
git bisect good db5d39a66f1285f78321d953eac398feaedfc63d
# good: [d6337146bb99a20c96c89b7693f4ad726455f6ba] xdg_shell: improve xdg_positioner resize calculations
git bisect good d6337146bb99a20c96c89b7693f4ad726455f6ba
# bad: [d724556b7ece61a5ff4eb764e6f47ec8089439bf] input: fix virtual devices not updating capabilities (#6366)
git bisect bad d724556b7ece61a5ff4eb764e6f47ec8089439bf
# bad: [6967a31450441fc5605c05db6f65505dace4b263] wayland/core: move to new impl (#6268)
git bisect bad 6967a31450441fc5605c05db6f65505dace4b263
# good: [40ce17bbbd6b01c7d5061358e5ff318122759a9e] gestures: Add gestures:workspace_swipe_min_fingers option (#6342)
git bisect good 40ce17bbbd6b01c7d5061358e5ff318122759a9e
# good: [c31d9ef4172452f6f219f91d9b87a24d91f0cf3a] xdg_shell: fix nested xdg_positioner calculations
git bisect good c31d9ef4172452f6f219f91d9b87a24d91f0cf3a
# first bad commit: [6967a31450441fc5605c05db6f65505dace4b263] wayland/core: move to new impl (#6268)

I tried bisect and found out the first bad commit is 6967a31450441fc5605c05db6f65505dace4b263. Hope this will help.

vaxerski commented 1 month ago

I assume kicad is xwayland? in that case dup of #6584

Isoheptane commented 1 month ago

I assume kicad is xwayland? in that case dup of #6584

I'm running KiCAD (8.0.3) natively on Wayland.

Window 58fe2d0e2ab0 -> Choose Footprint (13802 items loaded):
    mapped: 1
    hidden: 0
    at: 1173,75
    size: 1950,1035
    workspace: 1 (1)
    floating: 1
    pseudo: 0
    monitor: 0
    class: kicad
    title: Choose Footprint (13802 items loaded)
    initialClass: kicad
    initialTitle: Choose Footprint (13802 items loaded)
    pid: 2257801
    xwayland: 0
    pinned: 0
    fullscreen: 0
    fullscreenmode: 0
    fakefullscreen: 0
    grouped: 0
    tags:
    swallowing: 0
    focusHistoryID: 1

When running with GDK_BACKEND=x11, this bug won't reproduce. So it should be a issue related to Hyprland implementations.

I also noticed that the bigger (more pixels) the symbol preview is, the more memory it takes. Since Hyprland can still free up these memory, probably Hyprland is stocking up image buffer or something related to that but will not use them after generating them / free up the memory when they are no longer needed.

vaxerski commented 1 month ago

is it ram or vram? If VRAM, are you sure it's not just lazy freeing by the driver?

Isoheptane commented 1 month ago

is it ram or vram? If VRAM, are you sure it's not just lazy freeing by the driver?

Both RAM and VRAM. But it seems that the RAM usage increase is more severe than VRAM.

~ ❯❯❯ cat /proc/$(pidof Hyprland)/status | grep Vm
VmPeak:  7123744 kB
VmSize:  7121764 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:   6694172 kB
VmRSS:   6681740 kB
VmData:  3657764 kB
VmStk:       132 kB
VmExe:      4104 kB
VmLib:     66112 kB
VmPTE:     13384 kB
VmSwap:        0 kB
~ ❯❯❯ nvidia-smi | grep Hyprland
|    0   N/A  N/A   1775535      G   Hyprland                                     3939MiB |

VRAM usage won't drop either, so I don't think the driver is lazy freeing.

After closing KiCAD:

~ ❯❯❯ cat /proc/$(pidof Hyprland)/status | grep Vm
VmPeak:  7138148 kB
VmSize:  2166348 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:   6698124 kB
VmRSS:   1743052 kB
VmData:  1654184 kB
VmStk:       132 kB
VmExe:      4104 kB
VmLib:     66112 kB
VmPTE:      3704 kB
VmSwap:        0 kB
~ ❯❯❯ nvidia-smi | grep Hyprland
|    0   N/A  N/A   1775535      G   Hyprland                                      615MiB |
vaxerski commented 1 month ago

can you test under #6608?

Isoheptane commented 1 month ago

can you test under #6608?

Tested under aquamarine branch 5b1400f, this issue still exists.

vaxerski commented 1 month ago

patch.txt try this patch

Isoheptane commented 1 month ago

patch.txt try this patch

Tested on e8374e0 with this patch, but issue still exists.

vaxerski commented 1 month ago

This is a KiCAD issue (and shm leak)

Sway itself doesn't leak likely because IIRC sway does lazy alloc but it's definitely KiCad and it does the same (leaky) behavior on sway and hyprland:

[2809502.700] {Default Queue}  -> wl_shm#7.create_pool(new id wl_shm_pool#125, fd 21, 2393600)
[2809502.704] {Default Queue}  -> wl_shm_pool#125.create_buffer(new id wl_buffer#126, 0, 880, 680, 3520, 0)

This buffer created is never referenced again (and neither is the pool) and KiCAD keeps creating them, thus having Hyprland allocate memory for it, thus increasing the VmRSS.

With sway, the leak is still there, but it will likely show up only on KiCAD's memory usage because it's only shared mem.