apache/cassandra · error · RuntimeException
Cannot allocated space for a heap dump snapshot. There are…
Error message
Cannot allocated space for a heap dump snapshot. There are only
What it means
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.
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
Example fix
// before (cassandra.yaml): heap_dump_path: /var/lib/cassandra # volume only 50GB free, 64GB heap // after (cassandra.yaml): heap_dump_path: /mnt/dump-volume # volume with >128GB free
Defensive patterns
Strategy: validation
Validate before calling
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); Try / catch
try { HeapUtils.maybeCreateHeapDump(); } catch (RuntimeException e) { logger.error("Heap dump skipped (disk space): {}", e.getMessage()); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- Cannot create heap dump unless -XX:HeapDumpPath or…
- Addresses differ: !=
- Attempted to get heap dump path without -XX:HeapDumpPath or…
- CMS Membership differ
- Detected duplicate rows for during .
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/c9b786ce9df54aa4.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/utils/HeapUtils.java:118
if (DatabaseDescriptor.getDumpHeapOnUncaughtException())
{
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
Path absoluteBasePath = DatabaseDescriptor.getHeapDumpPath();
// We should never reach this point with this value null as we initialize the bool only after confirming
// the -XX param / .yaml conf is present on initial init and the JMX entry point, but still worth checking.
if (absoluteBasePath == null)
{
DatabaseDescriptor.setDumpHeapOnUncaughtException(false);
throw new RuntimeException("Cannot create heap dump unless -XX:HeapDumpPath or cassandra.yaml:heap_dump_path is specified.");
}
long maxMemoryBytes = Runtime.getRuntime().maxMemory();
long freeSpaceBytes = PathUtils.tryGetSpace(absoluteBasePath, FileStore::getUnallocatedSpace);
// Abort if there isn't enough room on the target disk to dump the entire heap and then copy it.
if (freeSpaceBytes < 2 * maxMemoryBytes)
throw new RuntimeException("Cannot allocated space for a heap dump snapshot. There are only " + freeSpaceBytes + " bytes free at " + absoluteBasePath + '.');
HotSpotDiagnosticMXBean mxBean = ManagementFactory.newPlatformMXBeanProxy(server, "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
String filename = String.format("pid%s-epoch%s.hprof", HeapUtils.getProcessId().toString(), currentTimeMillis());
String fullPath = File.getPath(absoluteBasePath.toString(), filename).toString();
logger.info("Writing heap dump to {} on partition w/ {} free bytes...", absoluteBasePath, freeSpaceBytes);
mxBean.dumpHeap(fullPath, false);
logger.info("Heap dump written to {}", fullPath);
// Disable further heap dump creations until explicitly re-enabled.
DatabaseDescriptor.setDumpHeapOnUncaughtException(false);
return fullPath;
}
}
catch (Throwable e)
{
logger.warn("Unable to create heap dump.", e);View on GitHub (pinned to 88fd0f6a0e)