From 61978bbe693c020ffa29dee17b81072ac52726e0 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Thu, 6 Jan 2022 16:54:01 -0800 Subject: [PATCH] Purge all if the last thread migrated away from an arena. --- src/jemalloc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/jemalloc.c b/src/jemalloc.c index fb435248..2ffb9f03 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -472,6 +472,12 @@ arena_migrate(tsd_t *tsd, unsigned oldind, unsigned newind) { arena_nthreads_dec(oldarena, false); arena_nthreads_inc(newarena, false); tsd_arena_set(tsd, newarena); + + if (arena_nthreads_get(oldarena, false) == 0) { + /* Purge if the old arena has no associated threads anymore. */ + arena_decay(tsd_tsdn(tsd), oldarena, + /* is_background_thread */ false, /* all */ true); + } } static void