From 114d698fdeb53c73734df16e68828154fbc1527e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 3 Nov 2020 15:55:35 +0100 Subject: [PATCH] MEDIUM: pattern: call malloc_trim() on pat_ref_reload() This is one case where we may release large amounts of data at once. Tests show that without this, after 10 full reloads of an ACL containing 1M IP addresses, the memory usage grew and stabilized around 1.7 GB of RSS. With this change, it stays around 260 MB and is stable across reloads. --- src/pattern.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pattern.c b/src/pattern.c index 4a3fe297e..e0285459b 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -2101,6 +2101,10 @@ void pat_ref_reload(struct pat_ref *ref, struct pat_ref *replace) HA_RWLOCK_WRUNLOCK(PATEXP_LOCK, &expr->lock); } HA_SPIN_UNLOCK(PATREF_LOCK, &ref->lock); + +#if defined(HA_HAVE_MALLOC_TRIM) + malloc_trim(0); +#endif } /* This function prunes all entries of . This function