--- layout: docu redirect_from: - /docs/extensions/jemalloc - /docs/extensions/current/jemalloc - /docs/stable/extensions/jemalloc - /docs/stable/core_extensions/jemalloc - /docs/current/core_extensions/jemalloc - /docs/lts/core_extensions/jemalloc - /docs/preview/core_extensions/jemalloc - /docs/internals/jemalloc - /docs/stable/internals/jemalloc - /docs/current/internals/jemalloc - /docs/lts/internals/jemalloc - /docs/preview/internals/jemalloc title: jemalloc --- On supported platforms, DuckDB replaces the system's memory allocator with [jemalloc](https://jemalloc.net/). `jemalloc` is statically linked into DuckDB and cannot be installed or loaded during runtime. > For technical reasons, we used to distribute `jemalloc` as an extension. Since DuckDB 1.5.3, it is distributed as a third-party library. ## Operating System Support The availability of `jemalloc` depends on the operating system. ### Linux 64-bit Linux distributions of DuckDB ship with `jemalloc` by default (with the exception of builds for musl-based distributions). To disable `jemalloc`, [build DuckDB from source]({% link docs/2.0/dev/building/overview.md %}) and set the `BUILD_JEMALLOC` flag to `0` as follows: ```batch GEN=ninja BUILD_JEMALLOC=0 make ``` This flag is passed to CMake as `-DENABLE_JEMALLOC=0`. ### macOS and Windows On macOS and Windows, `jemalloc` is not available. DuckDB uses the system's memory allocator on these platforms. ## Configuration ### Environment Variables The jemalloc allocator in DuckDB can be configured via the `DUCKDB_JE_MALLOC_CONF` environment variable. Setting this is equivalent to setting the [`MALLOC_CONF` environment variable](https://jemalloc.net/jemalloc.3.html#environment) for jemalloc but DuckDB uses a different environment variable name to avoid potential name clashes with other applications. ### Background Threads By default, jemalloc's [background threads](https://jemalloc.net/jemalloc.3.html#background_thread) are disabled. To enable them, use the following configuration option: ```sql SET allocator_background_threads = true; ``` Background threads asynchronously purge outstanding allocations so that this doesn't have to be done synchronously by the foreground threads. This improves allocation performance, and should be noticeable in allocation-heavy workloads, especially on many-core CPUs.