Bug 496736 - KWin X11 memory leak after exiting a program written with SDL
Summary: KWin X11 memory leak after exiting a program written with SDL
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: performance (other bugs)
Version First Reported In: 6.2.4
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: X11-only
Depends on:
Blocks:
 
Reported: 2024-11-27 03:47 UTC by emberqualia
Modified: 2025-02-24 17:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Minimal SDL2 example code (440 bytes, text/x-c++src)
2024-11-27 03:47 UTC, emberqualia
Details

Note You need to log in before you can comment on or make changes to this bug.
Description emberqualia 2024-11-27 03:47:54 UTC
Created attachment 176159 [details]
Minimal SDL2 example code

SUMMARY

Every time I close my program written in C++ with SDL, KWin (the KDE window manager) leaks memory, anywhere from 1 to 10 MB at a time. After about 1 GB has leaked, KWin starts to get unstable, and it crashes soon thereafter.

STEPS TO REPRODUCE

1. Run "g++ -lSDL2 sdl2.cpp" to compile the attached C++ code, which is a minimal SDL3 app
2. Run the compiled program and then close it

OBSERVED RESULT

KWin leaks memory, eventually to the point of a crash.

EXPECTED RESULT

It shouldn't leak memory.

SOFTWARE/OS VERSIONS

Operating System: Arch Linux 
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.12.1-zen1-1-zen (64-bit)
Graphics Platform: X11
Processors: 20 × 13th Gen Intel® Core™ i9-13900H
Memory: 31.0 GiB of RAM
Graphics Processor: Mesa Intel® Graphics

ADDITIONAL INFORMATION

This issue happens with both SDL2 and SDL3.

I often see the following error in the console after closing the program:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  40 (X_TranslateCoords)
  Resource id in failed request:  0x7e171fc
  Serial number of failed request:  560
  Current serial number in output stream:  560
Comment 1 TraceyC 2025-02-24 17:59:09 UTC
Adding the x11-only keyword