{"record":{"id":"c9b786ce9df54aa4","repo":"apache/cassandra","slug":"cannot-allocated-space-for-a-heap-dump-snapshot-t","errorCode":null,"errorMessage":"Cannot allocated space for a heap dump snapshot. There are only ","messagePattern":"Cannot allocated space for a heap dump snapshot\\. There are only ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/utils/HeapUtils.java","lineNumber":118,"sourceCode":"                if (DatabaseDescriptor.getDumpHeapOnUncaughtException())\n                {\n                    MBeanServer server = ManagementFactory.getPlatformMBeanServer();\n\n                    Path absoluteBasePath = DatabaseDescriptor.getHeapDumpPath();\n                    // We should never reach this point with this value null as we initialize the bool only after confirming\n                    // the -XX param / .yaml conf is present on initial init and the JMX entry point, but still worth checking.\n                    if (absoluteBasePath == null)\n                    {\n                        DatabaseDescriptor.setDumpHeapOnUncaughtException(false);\n                        throw new RuntimeException(\"Cannot create heap dump unless -XX:HeapDumpPath or cassandra.yaml:heap_dump_path is specified.\");\n                    }\n\n                    long maxMemoryBytes = Runtime.getRuntime().maxMemory();\n                    long freeSpaceBytes = PathUtils.tryGetSpace(absoluteBasePath, FileStore::getUnallocatedSpace);\n\n                    // Abort if there isn't enough room on the target disk to dump the entire heap and then copy it.\n                    if (freeSpaceBytes < 2 * maxMemoryBytes)\n                        throw new RuntimeException(\"Cannot allocated space for a heap dump snapshot. There are only \" + freeSpaceBytes + \" bytes free at \" + absoluteBasePath + '.');\n\n                    HotSpotDiagnosticMXBean mxBean = ManagementFactory.newPlatformMXBeanProxy(server, \"com.sun.management:type=HotSpotDiagnostic\", HotSpotDiagnosticMXBean.class);\n                    String filename = String.format(\"pid%s-epoch%s.hprof\", HeapUtils.getProcessId().toString(), currentTimeMillis());\n                    String fullPath = File.getPath(absoluteBasePath.toString(), filename).toString();\n\n                    logger.info(\"Writing heap dump to {} on partition w/ {} free bytes...\", absoluteBasePath, freeSpaceBytes);\n                    mxBean.dumpHeap(fullPath, false);\n                    logger.info(\"Heap dump written to {}\", fullPath);\n\n                    // Disable further heap dump creations until explicitly re-enabled.\n                    DatabaseDescriptor.setDumpHeapOnUncaughtException(false);\n\n                    return fullPath;\n                }\n            }\n            catch (Throwable e)\n            {\n                logger.warn(\"Unable to create heap dump.\", e);","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/utils/HeapUtils.java#L100-L136","documentation":"HeapUtils.maybeCreateHeapDump requires free disk space of at least twice the JVM max heap (heap dump plus a copy). This RuntimeException is thrown when the FileStore hosting the configured heap dump path has less than 2 * maxMemoryBytes unallocated space, aborting the dump before writing.","triggerScenarios":"dump_heap_on_uncaught_exception triggers maybeCreateHeapDump while the disk/volume containing heap_dump_path has freeSpaceBytes < 2 * Runtime.maxMemory(), e.g. a 32GB-heap node dumping to a volume with only 40GB free.","commonSituations":"Small or nearly-full data volumes used for heap dumps, large heaps (64GB+) on modest disks, heap dump path sharing the Cassandra data disk that is already close to capacity.","solutions":["Free space on the volume holding the heap dump path (delete old hprof files)","Point heap_dump_path / -XX:HeapDumpPath at a volume with at least 2x max heap free","Reduce the heap size if the node is over-allocated relative to disk capacity","Expand the disk/volume used for heap dumps"],"exampleFix":"// before (cassandra.yaml): heap_dump_path: /var/lib/cassandra  # volume only 50GB free, 64GB heap\n// after (cassandra.yaml):  heap_dump_path: /mnt/dump-volume    # volume with >128GB free","handlingStrategy":"validation","validationCode":"long need = 2 * Runtime.getRuntime().maxMemory(); long free = new File(heapDumpPath).getUsableSpace(); if (free < need) logger.error(\"heap dump path needs {} free bytes, only {} available\", need, free);","typeGuard":null,"tryCatchPattern":"try { HeapUtils.maybeCreateHeapDump(); } catch (RuntimeException e) { logger.error(\"Heap dump skipped (disk space): {}\", e.getMessage()); }","preventionTips":["Provision the heap dump volume with at least 2x max heap free space","Clean up old *.hprof files via a scheduled job","Monitor disk free space on the heap dump path and alert below 2x heap","Point heap_dump_path at a dedicated volume separate from data disks"],"tags":["heap-dump","disk-space","diagnostics"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}