MEDIUM: pools: call malloc_trim() from pool_gc()
authorWilly Tarreau <w@1wt.eu>
Tue, 3 Nov 2020 14:53:34 +0000 (15:53 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 May 2021 05:56:36 +0000 (07:56 +0200)
If available it definitely makes sense to call it since it's also
called when stopping to reclaim the maximum possible memory.

(cherry picked from commit 88366c2926deac5ee257b6c541633b6a8b5111b3)
[wt: backported as it helps not only on reload but also on SIGQUIT to
     try to return all unused memory]
Signed-off-by: Willy Tarreau <w@1wt.eu>

src/pool.c

index 5130efb..03cb2ec 100644 (file)
@@ -359,6 +359,10 @@ void pool_gc(struct pool_head *pool_ctx)
 
        if (!isolated)
                thread_release();
+
+#if defined(HA_HAVE_MALLOC_TRIM)
+       malloc_trim(0);
+#endif
 }
 
 #else /* CONFIG_HAP_LOCKLESS_POOLS */