Commit d0ba4693 authored by Richard Hughes's avatar Richard Hughes
Browse files

Drop unused heap pages after startup has completed

Although glibc calls this when memory gets low automatically, we can invoke it
manually when we've loaded all plugins and coldplugged all devices.

This has no effect when using proper heap benchmarks like massif, but random
Reddit users just looking at the RSS column in an 'easy-to-use memory profiler'
will see a much lower numbers.

Where this feature might actually be useful is after a libxmlb metadata rebuild
where we dirtied a lot of heap just parsing XML.
parent 1bf5d32e
......@@ -14,6 +14,7 @@
#include <glib/gi18n.h>
#include <glib-unix.h>
#include <locale.h>
#include <malloc.h>
#include <polkit/polkit.h>
......@@ -2036,6 +2037,9 @@ main (int argc, char *argv[])
else if (timed_exit)
g_timeout_add_seconds (5, fu_main_timed_exit_cb, priv->loop);
/* drop heap except one page */
malloc_trim (4096);
/* wait */
g_message ("Daemon ready for requests (locale %s)", g_getenv ("LANG"));
g_main_loop_run (priv->loop);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment