swaywm / swaybg

Wallpaper tool for Wayland compositors
MIT License
490 stars 31 forks source link

Fix memory leak when using image tile mode #40

Closed mstoeckl closed 2 years ago

mstoeckl commented 2 years ago

This fixes a significant memory leak which occurs when using the tile image scaling mode; it was brought to my attention by https://github.com/swaywm/swaybg/issues/14#issuecomment-1059096139 .

To test this change, run a nested instance of Sway; inside it, run swaybg -i image.jpg -m tile; and then resize the nested Sway several times, and watch its memory usage. Before this change, every time the frame was redrawn, a copy of the pixel data for image.jpg would be leaked; for large images, this can be a few hundred MB, every time.

cab404 commented 2 years ago

Thank you!

cab404 commented 2 years ago

@emersion will there be a minor release, so I can bump it in Nixpkgs?

emersion commented 2 years ago

Maybe next week -- will wait for a while to make sure no more patches come in.