Skip to content

memory leak fix proposal #10

Description

@markulrich1966

Hello,

When using idesk in combination with an external background-changing script (like icewmbg cycling wallpapers every 20 seconds), idesk's memory usage balloons rapidly up to 2-3 GBs within a short period.

The root cause is located in src/XDesktopContainer.cpp inside XDesktopContainer::initXWin().
Currently, idesk registers for root window changes via:
XSelectInput( display, rootWindow, PropertyChangeMask| SubstructureNotifyMask);

Since idesk ignores most of these background/structure change events in its switch-case loops, the raw X11 event structures pile up endlessly inside Xlib's internal event queue, flooding the process heap and creating a massive memory leak.

Fix applied and verified:
Changing the mask to 0 (or removing PropertyChangeMask and SubstructureNotifyMask) stops the X server from flooding the queue, safely stabilizing idesk's memory footprint at a flat ~31 MB without affecting icon functionality or layer styling.

Modified code section in src/XDesktopContainer.cpp:

void XDesktopContainer::initXWin()
{
     // ...
     prop.nitems = strlen(name);
     XSetTextProperty(display, rootWindow, &prop, start);
     
     // FIX: Remove PropertyChangeMask and SubstructureNotifyMask to prevent event flood leak
     XSelectInput( display, rootWindow, 0 );
     
     XSync(display, false);
}

Please consider merging this fix or updating the root window event mask to prevent this severe memory leak for users with dynamic wallpapers.

Please note: I am not a C++ coder, so solved this using the gemini AI from google.

Best regards!
Mark

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions