#2815·jemalloc

Memory leak: `arena_extent_dalloc()` is not called for extents for which `arena_extent_split()` failed

Author: ldorauCreated Mar 14, 2025Updated May 15, 2025

There is a memory leak: arena_extent_dalloc() is not called for extents for which arena_extent_split() failed

An example "trace" from gdb (breakpoints were set in all jemalloc hooks):

arena_extent_alloc (extent_hooks=0x7ffff7da6640 <arena_extent_hooks>, new_addr=0x0, size=2097152, alignment=4096, zero=0x7fffffffbf1e, commit=0x7fffffffbf1f, arena_ind=49)
arena_extent_split (extent_hooks=0x7ffff7da6640 <arena_extent_hooks>, addr=0x7ffff67ff000, size=2097152, size_a=4096, size_b=2093056, committed=true, arena_ind=49) - FAILED
arena_extent_alloc (extent_hooks=0x7ffff7da6640 <arena_extent_hooks>, new_addr=0x0, size=4096, alignment=4096, zero=0x7fffffffbe6c, commit=0x7fffffffbf1d, arena_ind=49)
arena_extent_dalloc (extent_hooks=0x7ffff7da6640 <arena_extent_hooks>, addr=0x7ffff7702000, size=4096, committed=true, arena_ind=49)

As you can see above arena_extent_dalloc() was not called for the first allocated extent.

jemalloc commit: 81f35e0b55c52cb0c3e1171afd477e1cb66fafaf

Ref: https://github.com/oneapi-src/unified-memory-framework/pull/902#issuecomment-2721334161