diff --git a/config.h.meson b/config.h.meson index 09e95b221..094d79616 100644 --- a/config.h.meson +++ b/config.h.meson @@ -132,3 +132,6 @@ /* Supports timerfd_create/timerfd_settime */ #mesondefine HAVE_TIMERFD + +/* Supports malloc_trim */ +#mesondefine HAVE_MALLOC_TRIM diff --git a/meson.build b/meson.build index 5a741631c..c2c9c8bb7 100644 --- a/meson.build +++ b/meson.build @@ -345,6 +345,8 @@ int main (int argc, char ** argv) { } ''', name : 'timerfd_create(2) system call') +have_malloc_trim = meson.get_compiler('c').has_function('malloc_trim') + have_documentation = get_option('docs') have_tests = get_option('tests') have_core_tests = false @@ -570,6 +572,7 @@ cdata.set('HAVE_PROFILER', have_profiler) cdata.set('HAVE_LIBDISPLAY_INFO', have_libdisplay_info) cdata.set('HAVE_PANGO_FT2', have_pango_ft2) cdata.set('HAVE_TIMERFD', have_timerfd) +cdata.set('HAVE_MALLOC_TRIM', have_malloc_trim) if have_x11_client xkb_base = xkeyboard_config_dep.get_variable('xkb_base') diff --git a/src/compositor/meta-background-image.c b/src/compositor/meta-background-image.c index c27c36e1b..508a63440 100644 --- a/src/compositor/meta-background-image.c +++ b/src/compositor/meta-background-image.c @@ -23,6 +23,10 @@ #include #include +#ifdef HAVE_MALLOC_TRIM +#include +#endif + #include "clutter/clutter.h" #include "compositor/cogl-utils.h" @@ -135,6 +139,10 @@ load_file (GTask *task, pixbuf = gdk_pixbuf_new_from_stream (G_INPUT_STREAM (stream), NULL, &error); g_object_unref (stream); +#ifdef HAVE_MALLOC_TRIM + malloc_trim (0); +#endif + if (pixbuf == NULL) { g_task_return_error (task, error);