[BUG]: Memory leak in transparency_manager #398

Closed
opened 2026-01-05 14:50:22 +01:00 by adam · 4 comments
Owner

Originally created by @CtByte on GitHub (Jun 2, 2024).

Describe the bug
When the "transparency": true setting is used, there is a memory leak that happens when an inactive program cannot be transparent.


To Reproduce
Steps to reproduce the behavior:

  1. Add "transparency": true and "transparency_alpha": 210 to the config
  2. Open a program that can be transparent and an other that cannot (ex: Visual Studio Community 2022).
  3. Observe komorebi.exe in the Task Manager
  4. When the program that cannot be transparent becomes inactive the memory consumption rises

I only found Visual Studio to not allow transparecy so far.

Microsoft Visual Studio Community 2022 (64-bit)
Version 17.9.7

Screenshots and Logs

Typical MEM is around 40 MB. After leaving Komorebi run for a while MEM is over 3 GB.

Screenshot 2024-06-01 222334

When I run Komorebi locally, it starts to spam this warning when VS becomes inactive.

2024-06-02T11:37:24.531516Z  INFO komorebi::transparency_manager: listening
2024-06-02T11:37:24.532153Z  WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057)
2024-06-02T11:37:24.532317Z  INFO komorebi::transparency_manager: listening
2024-06-02T11:37:24.532934Z  WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057)
2024-06-02T11:37:24.533093Z  INFO komorebi::transparency_manager: listening
2024-06-02T11:37:24.533891Z  WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057)
2024-06-02T11:37:24.534000Z  INFO komorebi::transparency_manager: listening
2024-06-02T11:37:24.534698Z  WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057)
2024-06-02T11:37:24.534864Z  INFO komorebi::transparency_manager: listening
2024-06-02T11:37:24.535537Z  WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057)
2024-06-02T11:37:24.535667Z  INFO komorebi::transparency_manager: listening
2024-06-02T11:37:24.536364Z  WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057)
2024-06-02T11:37:24.536459Z  INFO komorebi::transparency_manager: listening
2024-06-02T11:37:24.537126Z  WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057)

Operating System

OS Name:                   Microsoft Windows 11 Pro
OS Version:                10.0.22631 N/A Build 22631
Originally created by @CtByte on GitHub (Jun 2, 2024). **Describe the bug** When the `"transparency": true` setting is used, there is a memory leak that happens when an inactive program cannot be transparent. --- **To Reproduce** Steps to reproduce the behavior: 1. Add `"transparency": true` and `"transparency_alpha": 210` to the config 2. Open a program that can be transparent and an other that cannot (ex: Visual Studio Community 2022). 3. Observe `komorebi.exe` in the Task Manager 4. When the program that cannot be transparent becomes inactive the memory consumption rises I only found Visual Studio to not allow transparecy so far. ``` Microsoft Visual Studio Community 2022 (64-bit) Version 17.9.7 ``` --- **Screenshots and Logs** Typical MEM is around 40 MB. After leaving Komorebi run for a while MEM is over 3 GB. <img width="560" alt="Screenshot 2024-06-01 222334" src="https://github.com/LGUG2Z/komorebi/assets/165908630/306d5868-232a-4915-8250-5f5c34bfd32e"> When I run Komorebi locally, it starts to spam this warning when VS becomes inactive. ``` 2024-06-02T11:37:24.531516Z INFO komorebi::transparency_manager: listening 2024-06-02T11:37:24.532153Z WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057) 2024-06-02T11:37:24.532317Z INFO komorebi::transparency_manager: listening 2024-06-02T11:37:24.532934Z WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057) 2024-06-02T11:37:24.533093Z INFO komorebi::transparency_manager: listening 2024-06-02T11:37:24.533891Z WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057) 2024-06-02T11:37:24.534000Z INFO komorebi::transparency_manager: listening 2024-06-02T11:37:24.534698Z WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057) 2024-06-02T11:37:24.534864Z INFO komorebi::transparency_manager: listening 2024-06-02T11:37:24.535537Z WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057) 2024-06-02T11:37:24.535667Z INFO komorebi::transparency_manager: listening 2024-06-02T11:37:24.536364Z WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057) 2024-06-02T11:37:24.536459Z INFO komorebi::transparency_manager: listening 2024-06-02T11:37:24.537126Z WARN komorebi::transparency_manager: restarting failed thread: The parameter is incorrect. (0x80070057) ``` --- **Operating System** ``` OS Name: Microsoft Windows 11 Pro OS Version: 10.0.22631 N/A Build 22631 ```
adam added the bug label 2026-01-05 14:50:22 +01:00
adam closed this issue 2026-01-05 14:50:22 +01:00
Author
Owner

@LGUG2Z commented on GitHub (Jun 2, 2024):

Of course it would be a Microsoft application 🙃

I think we can probably refactor this to log the error instead of propagate it to the thread handler which should stop the global state tracker from filling up on every thread restart.

@LGUG2Z commented on GitHub (Jun 2, 2024): Of course it would be a Microsoft application 🙃 I think we can probably refactor this to log the error instead of propagate it to the thread handler which should stop the global state tracker from filling up on every thread restart.
Author
Owner

@CtByte commented on GitHub (Jun 2, 2024):

I'll be happy to test again so you are not forced to dirty your system with VS 😉

To be fair, there might be other programs out there, but Microsoft VS is one of them for sure.

@CtByte commented on GitHub (Jun 2, 2024): I'll be happy to test again so you are not forced to dirty your system with VS 😉 To be fair, there might be other programs out there, but Microsoft VS is one of them for sure.
Author
Owner

@LGUG2Z commented on GitHub (Jun 2, 2024):

The commit above should address the memory ballooning issue 🤞

@LGUG2Z commented on GitHub (Jun 2, 2024): The commit above should address the memory ballooning issue 🤞
Author
Owner

@CtByte commented on GitHub (Jun 2, 2024):

It is working. The output is now:

2024-06-02T21:23:18.320713Z  INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 265250 })}: komorebi::process_event: processed: (hwnd: 265250, title: Developer PowerShell Visual Studio Community 2022 17.9.34902.65, exe: WindowsTerminal.exe, class: CASCADIA_HOSTING_WINDOW_CLASS)
2024-06-02T21:23:18.322339Z ERROR komorebi::transparency_manager: failed to make unfocused window 265250 transparent: The parameter is incorrect. (0x80070057)

Thank you very much for the quick response as always!

@CtByte commented on GitHub (Jun 2, 2024): It is working. The output is now: ``` 2024-06-02T21:23:18.320713Z INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 265250 })}: komorebi::process_event: processed: (hwnd: 265250, title: Developer PowerShell Visual Studio Community 2022 17.9.34902.65, exe: WindowsTerminal.exe, class: CASCADIA_HOSTING_WINDOW_CLASS) 2024-06-02T21:23:18.322339Z ERROR komorebi::transparency_manager: failed to make unfocused window 265250 transparent: The parameter is incorrect. (0x80070057) ``` Thank you very much for the quick response as always!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/komorebi#398