[GH-ISSUE #972] Possible memory leak with cairo widgets #7326

Closed
opened 2026-05-23 02:53:55 +01:00 by JakeStanger · 4 comments
Owner

Originally created by @kafeinnet on GitHub (May 12, 2025).
Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/972

Describe the bug

If I add a cairo widget, the memory usage of the ironbar process increase quite quickly.
The process is OOM-killed after ~1h of idling.

To reproduce
Steps to reproduce the behavior:

  1. Add a simple cairomodule (see below for the code)
  2. Monitor the memory usage of the ironbar process
  3. Wait a little bit and observe the memory usage increase
  4. Repeat without this test widget and observe the memory usage not increasing

Expected behavior

The memory usage of the ironbar process should not increase.

System information:

  • Distro: I use Arch Linux btw
  • Compositor: niri
  • Ironbar version: git

Configuration

Config
{
  $test = {
    orientation = "horizontal"
    direction = "vertical"
    name = "test"
    type = "cairo"
    path = "/home/fab/.config/ironbar/lua/test.lua"
    frequency = 500
    width = 20
    height = 200
  }
} in {
  monitors.DP-1 = {
    anchor_to_edges = true
    position = "left"
    start = [
      $test
    ]
    center = [
    ]
    end = [
    ]
  }
}
Widget lua code
function draw(cr)
  -- Draw widget
  local y = 20
  local x = 20

  cr:set_font_size(16)
  cr:move_to(x, y)
  cr:show_text("A")

  return 0
end

Additional context

I observed this behavior on two computers, both on Arch Linux.

Originally created by @kafeinnet on GitHub (May 12, 2025). Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/972 **Describe the bug** If I add a cairo widget, the memory usage of the ironbar process increase quite quickly. The process is OOM-killed after ~1h of idling. **To reproduce** Steps to reproduce the behavior: 1. Add a simple `cairo`module (see below for the code) 2. Monitor the memory usage of the ironbar process 3. Wait a little bit and observe the memory usage increase 4. Repeat without this `test` widget and observe the memory usage not increasing **Expected behavior** The memory usage of the ironbar process should not increase. **System information:** - Distro: I use Arch Linux btw - Compositor: niri - Ironbar version: git **Configuration** <details><summary>Config</summary> ```corn { $test = { orientation = "horizontal" direction = "vertical" name = "test" type = "cairo" path = "/home/fab/.config/ironbar/lua/test.lua" frequency = 500 width = 20 height = 200 } } in { monitors.DP-1 = { anchor_to_edges = true position = "left" start = [ $test ] center = [ ] end = [ ] } } ``` </details> <details><summary>Widget lua code</summary> ```lua function draw(cr) -- Draw widget local y = 20 local x = 20 cr:set_font_size(16) cr:move_to(x, y) cr:show_text("A") return 0 end ``` </details> **Additional context** I observed this behavior on two computers, both on Arch Linux.
Author
Owner

@kafeinnet commented on GitHub (May 12, 2025):

To be sure, I graphed the memory usage with and without a cairo plugin (and my full config).

With a cairo widget:

Image

Without a cairo widget:

Image

<!-- gh-comment-id:2872266848 --> @kafeinnet commented on GitHub (May 12, 2025): To be sure, I graphed the memory usage with and without a cairo plugin (and my full config). With a cairo widget: ![Image](https://github.com/user-attachments/assets/e43782ed-39fe-41d6-91df-d231882f42a3) Without a cairo widget: ![Image](https://github.com/user-attachments/assets/fa2f3d0d-12ef-4d9e-99c1-af32401cec38)
Author
Owner

@JakeStanger commented on GitHub (May 12, 2025):

Thanks for the detailed report. What's the unit for the bottom axis?

<!-- gh-comment-id:2872329208 --> @JakeStanger commented on GitHub (May 12, 2025): Thanks for the detailed report. What's the unit for the bottom axis?
Author
Owner

@kafeinnet commented on GitHub (May 12, 2025):

That's the time in seconds since the measuring started (one measure per second).

<!-- gh-comment-id:2872404861 --> @kafeinnet commented on GitHub (May 12, 2025): That's the time in seconds since the measuring started (one measure per second).
Author
Owner

@JakeStanger commented on GitHub (May 14, 2025):

Got it. Turns out if you increase a reference count you gotta decrease it again. Who knew...

Not even Rust is safe.

I've made some slight changes elsewhere that should have a (very small) improvement on memory/performance in addition.

<!-- gh-comment-id:2881630585 --> @JakeStanger commented on GitHub (May 14, 2025): Got it. Turns out if you increase a reference count you gotta decrease it again. Who knew... Not even Rust is safe. I've made some slight changes elsewhere that should have a (very small) improvement on memory/performance in addition.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JakeStanger/ironbar#7326
No description provided.