Skip to content
Commit 2fb12bbd authored by Siddhesh Poyarekar's avatar Siddhesh Poyarekar
Browse files

realloc: Limit chunk reuse to only growing requests [BZ #30579]



The trim_threshold is too aggressive a heuristic to decide if chunk
reuse is OK for reallocated memory; for repeated small, shrinking
allocations it leads to internal fragmentation and for repeated larger
allocations that fragmentation may blow up even worse due to the dynamic
nature of the threshold.

Limit reuse only when it is within the alignment padding, which is 2 *
size_t for heap allocations and a page size for mmapped allocations.
There's the added wrinkle of THP, but this fix ignores it for now,
pessimizing that case in favor of keeping fragmentation low.

This resolves BZ #30579.

Signed-off-by: default avatarSiddhesh Poyarekar <siddhesh@sourceware.org>
Reported-by: default avatarNicolas Dusart <nicolas@freedelity.be>
Reported-by: default avatarAurelien Jarno <aurelien@aurel32.net>
Reviewed-by: default avatarAurelien Jarno <aurelien@aurel32.net>
Tested-by: default avatarAurelien Jarno <aurelien@aurel32.net>
parent 320ac7ee
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment