Skip to content

Commit

Permalink
Dumping imlib2 cache after setting wallpaper to drastically decrease …
Browse files Browse the repository at this point in the history
…memory usage
  • Loading branch information
jzbor committed Feb 23, 2022
1 parent 27ec1db commit ef85d23
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/x11-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int x11_keyboard_has_changed(void) {
int x11_wallpaper_all(const char *path) {
#ifdef IMLIB2
unsigned int dpy_width, dpy_height, new_width, new_height, uidummy;
int depth, screen, i, status, idummy;
int depth, screen, i, status, idummy, cache_size;
double screen_ratio, image_ratio;
Visual *vis;
Window root, wdummy;
Expand Down Expand Up @@ -222,6 +222,11 @@ int x11_wallpaper_all(const char *path) {
imlib_free_color_range();
imlib_free_image();

/* drop imlib2 cache */
cache_size = imlib_get_font_cache_size();
imlib_set_cache_size(0);
imlib_set_cache_size(cache_size);

return status;
#else /* IMLIB2 */
return 0;
Expand Down

0 comments on commit ef85d23

Please sign in to comment.