[PATCH] malloc: Improve malloc initialization
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Thu Mar 27 14:29:06 GMT 2025
Hi Florian,
>> Or would you prefer calling ptmalloc_init explicitly during startup?
>
> That means the initialization could would run even if malloc is
> interposed. I wonder if that has adverse effects.
It would read some tunables and write a lots of global variables which are
never used afterwards. It's basically wasting cycles, but it's harmless.
We could avoid that by using function that would be overridden. Unfortunately
mallopt() is not supported by either Mimalloc or jemalloc, but we could call
malloc_usable_size (NULL) or posix_memalign (NULL, 0, 0) which could do
initialization without having any sideeffects in external allocators.
Cheers,
Wilco
More information about the Libc-alpha
mailing list