MadcowOG / dwl-bar

dwl-like bar for dwl
GNU General Public License v3.0
30 stars 10 forks source link

Memory Leak in Tray Icons. #15

Open Charadon opened 7 months ago

Charadon commented 7 months ago

There are a few memory leaks the tray icons patch. I found one of them as it was the worst one (Eating a gigabyte of memory an hour). In item.c in the item_render function, there is this line:

    int actual_size = cairo_image_surface_get_height(item->icon);
    icon_size = actual_size < icon_size ?
        actual_size * (icon_size / actual_size) : icon_size;
    cairo_surface_t *image = scale_icon(item->icon, icon_size, icon_size);
    cairo_set_source_surface(painter, image, *x+1, item->height - icon_size - 1);
    cairo_paint(painter);

image never gets freed. The fix is to add cairo_surface_destroy(image) after cairo_set_source_surface


There is another leak where i'm fairly certain that icons no longer shown don't get freed. However it's tricky to figure out where it is. But everytime a new icon spawns, it'll be allocated and not freed from what I can tell.