forked from haproxy/haproxy
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Your Feature Request
4.1) Memory allocation
By default, HAProxy uses the standard malloc() call provided by the libc. It
may also be built to use jemalloc, which is fast and thread-safe. In order to
use it, please add "-ljemalloc" to the ADDLIB variable. You may possibly also
need to append "-lpthread" and/or "-ldl" depending on the operating system.
No because malloc_trim() is a glibc-only function. Here we're emulating it, so if we find mallctl() we know we're running with jemalloc and we can use that code. Jemalloc like a few other alternative allocators (dlmalloc in the past, tcmalloc or mimalloc nowadays) are commonly used with LD_PRELOAD, so we don't know about their presence at build time but at runtime. However it's fine to use such external libs' capabilities in these cases, hence why mallctl() is sufficient here. The remaining test on using_default_allocator is to make sure that if we're using another allocator we don't yet know about but that we're already able to detect in a future version, we can stay safe and continue to avoid calling _malloc_trim(). And the test ends with the os-specific versions that usually come by default. Hoping this clarifies a little bit this whole mess.
What are you trying to do?
alloc ci
Output of haproxy -vv
12345
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels