[PATCH] malloc: Remove dynamic mmap/trim threshold [BZ #30769]

Florian Weimer fweimer@redhat.com
Thu Apr 2 07:12:22 GMT 2026


* Wilco Dijkstra:

> Whenever a large mmap is released the mmap and trim thresholds are updated.
> As a result these thresholds grow ever larger which means huge allocations
> are always served by arenas rather than mmap.  The thresholds can end up as
> large as an arena, which completely stops all trimming of the top block.
> Remove the code completely - the default thresholds seem way too low for
> modern 64-bit targets, but they can be increased separately.
>
> Passes regress - OK for commit?

General direction seems good to me.  The dynamic threshold is mentioned
in the manual:

     ‘M_MMAP_THRESHOLD’
          All chunks larger than this value are allocated outside the
          normal heap, using the ‘mmap’ system call.  This way it is
          guaranteed that the memory for these chunks can be returned to
          the system on ‘free’.  Note that requests smaller than this
          threshold might still be allocated via ‘mmap’.

          If this parameter is not set, the default value is set as 128
          KiB and the threshold is adjusted dynamically to suit the
          allocation patterns of the program.  If the parameter is set,
          the dynamic adjustment is disabled and the value is set
          statically to the input value.

So this needs to be updated.

Thanks,
Florian



More information about the Libc-alpha mailing list