{"record":{"id":"08b90fcc90a59495","repo":"apache/cassandra","slug":"out-of-native-memory-occured-you-can-avoid-it-by","errorCode":null,"errorMessage":"Out of native memory occured, You can avoid it by increasing the system ram space or by increasing bloom_filter_fp_chance.","messagePattern":"Out of native memory occured, You can avoid it by increasing the system ram space or by increasing bloom_filter_fp_chance\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/utils/obs/OffHeapBitSet.java","lineNumber":54,"sourceCode":" */\npublic class OffHeapBitSet implements IBitSet\n{\n    private final Memory bytes;\n\n    public OffHeapBitSet(long numBits)\n    {\n        /** returns the number of 64 bit words it would take to hold numBits */\n        long wordCount = (((numBits - 1) >>> 6) + 1);\n        if (wordCount > Integer.MAX_VALUE)\n            throw new UnsupportedOperationException(\"Bloom filter size is > 16GB, reduce the bloom_filter_fp_chance\");\n        try\n        {\n            long byteCount = wordCount * 8L;\n            bytes = Memory.allocate(byteCount);\n        }\n        catch (OutOfMemoryError e)\n        {\n            throw new RuntimeException(\"Out of native memory occured, You can avoid it by increasing the system ram space or by increasing bloom_filter_fp_chance.\");\n        }\n        // flush/clear the existing memory.\n        clear();\n    }\n\n    private OffHeapBitSet(Memory bytes)\n    {\n        this.bytes = bytes;\n    }\n\n    public long capacity()\n    {\n        return bytes.size() * 8;\n    }\n\n    @Override\n    public long offHeapSize()\n    {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/utils/obs/OffHeapBitSet.java#L36-L72","documentation":"OffHeapBitSet allocates its bit array off-heap via Memory.allocate; if the OS cannot supply byteCount native bytes (OutOfMemoryError), it wraps it in a RuntimeException advising more RAM or a higher bloom_filter_fp_chance. The filter size itself was legal (see the 16GB check) but physical native memory ran out.","triggerScenarios":"Constructing an OffHeapBitSet (bloom filter creation during memtable flush / compaction) when free off-heap/native memory is less than the requested byteCount.","commonSituations":"Very low bloom_filter_fp_chance on large tables combined with a small native memory budget or many concurrent compactions; container memory limits capping native allocations.","solutions":["Increase bloom_filter_fp_chance (ALTER TABLE ... WITH bloom_filter_fp_chance = 0.01) to shrink the allocation.","Add system RAM or raise container/native memory limits; verify with free/OS metrics.","Reduce concurrent compactions/flushes to lower peak native memory demand, or reduce SSTable sizes."],"exampleFix":"// before\nALTER TABLE t WITH bloom_filter_fp_chance = 0.001;\n// after\nALTER TABLE t WITH bloom_filter_fp_chance = 0.01;","handlingStrategy":"fallback","validationCode":"long byteCount = (((numBits - 1) >>> 6) + 1) * 8L;\nif (byteCount > Runtime.getRuntime().maxMemory()) logger.warn(\"bloom filter needs {} bytes native memory\", byteCount);","typeGuard":null,"tryCatchPattern":"try { new OffHeapBitSet(numBits); } catch (RuntimeException e) { /* fall back to smaller filter / higher fp chance */ }","preventionTips":["Size native memory to cover worst-case bloom filter allocations plus compaction overlap.","Avoid extreme bloom_filter_fp_chance values on very large tables.","Monitor native memory; in containers set explicit limits with headroom."],"tags":["out-of-memory","native-memory","bloom-filter","cassandra"],"backgroundTag":"out-of-native-memory","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"}