Configuring the heap dump directory

Analyzing the heap dump file can help troubleshoot memory problems. Java starts with the option -XX:+HeapDumpOnOutOfMemoryError. Using this option triggers a heap dump in the event of an out-of-memory condition. The heap dump file consists of references to objects that cause the heap to overflow. By default, the database puts the file a subdirectory of the working, root directory when running as a service. If the database does not have write permission to the root directory, the heap dump fails. If the root directory is too small to accommodate the heap dump, the server crashes.

The DataStax Help Center also provides troubleshooting information.

To ensure that a heap dump succeeds and to prevent crashes, configure a heap dump directory that is:

  • Accessible to the database for writing

  • Large enough to accommodate a heap dump

Base the size of the directory on the value of the Java -mx option.

Procedure

  1. Set the location of the heap dump in the cassandra-env.sh file.

  2. Open the cassandra-env.sh file for editing.

  3. Scroll down to the comment about the heap dump path:

    # set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR
    if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then
    JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof"
    fi
  4. On the line after the comment, set the CASSANDRA_HEAPDUMP_DIR to the desired path:

    # set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR
    export CASSANDRA_HEAPDUMP_DIR=<path>
    if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then
    JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof"
    fi
  5. Save the cassandra-env.sh file and restart.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com