]> sourceware.org Git - glibc.git/commit
malloc: Enable merging of remainders in memalign (bug 30723)
authorFlorian Weimer <fweimer@redhat.com>
Fri, 11 Aug 2023 09:18:17 +0000 (11:18 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 11 Aug 2023 09:18:17 +0000 (11:18 +0200)
commit542b1105852568c3ebc712225ae78b8c8ba31a78
treefd7101ea415b0f92af6e87e285bb2418846c734e
parent039ff51ac7e02db1cfc0c23e38ac7bfbb00221d1
malloc: Enable merging of remainders in memalign (bug 30723)

Previously, calling _int_free from _int_memalign could put remainders
into the tcache or into fastbins, where they are invisible to the
low-level allocator.  This results in missed merge opportunities
because once these freed chunks become available to the low-level
allocator, further memalign allocations (even of the same size are)
likely obstructing merges.

Furthermore, during forwards merging in _int_memalign, do not
completely give up when the remainder is too small to serve as a
chunk on its own.  We can still give it back if it can be merged
with the following unused chunk.  This makes it more likely that
memalign calls in a loop achieve a compact memory layout,
independently of initial heap layout.

Drop some useless (unsigned long) casts along the way, and tweak
the style to more closely match GNU on changed lines.

Reviewed-by: DJ Delorie <dj@redhat.com>
malloc/malloc.c
This page took 0.043605 seconds and 5 git commands to generate.