Skip to content

Commit 32896a9

Browse files
committed
Fix large allocation to search optimal size class heap.
Fix arena_run_alloc_large_helper() to not convert size to usize when searching for the first best fit via arena_run_first_best_fit(). This allows the search to consider the optimal quantized size class, so that e.g. allocating and deallocating 40 KiB in a tight loop can reuse the same memory. This regression was nominally caused by 5707d6f (Quantize szad trees by size class.), but it did not commonly cause problems until 8a03cf0 (Implement cache index randomization for large allocations.). These regressions were first released in 4.0.0. This resolves jemalloc#487.
1 parent e901263 commit 32896a9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/arena.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ arena_run_first_best_fit(arena_t *arena, size_t size)
10591059
static arena_run_t *
10601060
arena_run_alloc_large_helper(arena_t *arena, size_t size, bool zero)
10611061
{
1062-
arena_run_t *run = arena_run_first_best_fit(arena, s2u(size));
1062+
arena_run_t *run = arena_run_first_best_fit(arena, size);
10631063
if (run != NULL) {
10641064
if (arena_run_split_large(arena, run, size, zero))
10651065
run = NULL;

0 commit comments

Comments
 (0)