apache/cassandra · warning

jemalloc shared library could not be preloaded to speed up…

Error message

jemalloc shared library could not be preloaded to speed up memory allocations

What it means

A WARN log (not an exception) from the checkJemalloc startup check's execute(). Cassandra tries to preload libjemalloc to speed up native memory allocations; if the cassandra.libjemalloc system property is unset (jemalloc == null), jemalloc was not preloaded by the startup script and performance of off-heap allocations may suffer. If set to '-', preload was explicitly disabled (INFO), if set to a path, jemalloc is active (INFO).

Solutions

  1. Install jemalloc on the host (apt install libjemalloc2 / yum install jemalloc)
  2. Set the path explicitly via JVM opt -Dcassandra.libjemalloc=/path/to/libjemalloc.so.2 in jvm-server.options if it lives outside default search paths
  3. If preloading is intentionally unwanted, set cassandra.libjemalloc=- to record an explicit disable (removes the warning semantics)

Example fix

// before (jvm-server.options)
# nothing

// after
-Dcassandra.libjemalloc=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight: verify jemalloc can be located before starting the node
String jemalloc = System.getProperty("cassandra.libjemalloc");
String found = jemalloc != null ? jemalloc :
    java.util.stream.Stream.of("/usr/lib/x86_64-linux-gnu/libjemalloc.so.2", "/usr/lib64/libjemalloc.so.2")
        .filter(p -> new java.io.File(p).exists()).findFirst().orElse(null);
if (found == null) System.out.println("WARNING: libjemalloc not found; install it or set -Dcassandra.libjemalloc=<path>");

Prevention

When it happens

Trigger: checkJemalloc.execute() runs at node startup while CassandraRelevantProperties.LIBJEMALLOC is not set, meaning the startup script (cassandra-env.sh) could not find or load a jemalloc shared library (libjemalloc.so.2/libjemalloc.so.1).

Common situations: Minimal container images without jemalloc installed; jemalloc in a non-standard location not found by cassandra-env.sh; operators who removed it or run on distros where the package name differs (libjemalloc2 vs libjemalloc1).

Understand the failure class

Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/6176f87b00e2020e. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/service/StartupChecks.java:320

    };

    public static final StartupCheck checkJemalloc = new StartupCheck()
    {
        @Override
        public String name()
        {
            return "jemalloc";
        }

        @Override
        public void execute(StartupChecksConfiguration configuration)
        {
            if (configuration.isDisabled(name()))
                return;

            String jemalloc = CassandraRelevantProperties.LIBJEMALLOC.getString();
            if (jemalloc == null)
                logger.warn("jemalloc shared library could not be preloaded to speed up memory allocations");
            else if ("-".equals(jemalloc))
                logger.info("jemalloc preload explicitly disabled");
            else
                logger.info("jemalloc seems to be preloaded from {}", jemalloc);
        }
    };

    public static final StartupCheck checkLz4Native = new StartupCheck()
    {
        @Override
        public String name()
        {
            return "lz4_native";
        }

        @Override
        public void execute(StartupChecksConfiguration configuration)
        {

View on GitHub (pinned to 88fd0f6a0e)