Subject: Re: bug#45200: [PATCH] Force Glibc to free the memory freed

From: Eli Zaretskii <[email-masked]>
Date: Tue, 26 Jan 2021 16:49:53 +0200

> From: DJ Delorie <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked],
>         [email-masked], [email-masked]
> Date: Mon, 25 Jan 2021 17:17:27 -0500
> 
> Eli Zaretskii <[email-masked]> writes:
> > Thanks, but is it really a good idea to call malloc_trim each time we
> > free some chunk of memory?
> 
> malloc_trim() is very expensive relative to free(), partly because of
> what it needs to do, and partly because it flushes the fastbins cache.

How expensive?  Can you give some quantitative measure?

> If you call it every, say, 1000 iterations of free, that might suffice.
> Or perhaps after each GC run.

There's no guarantee that a full GC will call 'free', even though
that's quite likely.