Skip to content

alloc ci #16

@chipitsine

Description

@chipitsine

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions