nodejs/node · error
out of memory\n
Error message
out of memory\n
What it means
`BrotliDecoderCreateInstance(NULL, NULL, NULL)` returned NULL during decoder initialization in `InitDecoder`. The decoder allocator (which defaults to the system `malloc` when custom allocators are NULL) could not allocate the decoder state structure. This is an out-of-memory condition at the very start of decompression.
Source
Thrown at deps/brotli/c/tools/brotli.c:1201
if (context->comment_pos >= context->comment_len) {
context->comment_state = COMMENT_BAD;
return;
}
if (context->comment[context->comment_pos++] != data[i]) {
context->comment_state = COMMENT_BAD;
return;
}
}
if (context->comment_pos == context->comment_len) {
context->comment_state = COMMENT_OK;
}
}
}
static BROTLI_BOOL InitDecoder(Context* context) {
context->decoder = BrotliDecoderCreateInstance(NULL, NULL, NULL);
if (!context->decoder) {
fprintf(stderr, "out of memory\n");
return BROTLI_FALSE;
}
/* This allows decoding "large-window" streams. Though it creates
fragmentation (new builds decode streams that old builds don't),
it is better from used experience perspective. */
BrotliDecoderSetParameter(
context->decoder, BROTLI_DECODER_PARAM_LARGE_WINDOW, 1u);
if (context->dictionary) {
BrotliDecoderAttachDictionary(context->decoder,
BROTLI_SHARED_DICTIONARY_RAW, context->dictionary_size,
context->dictionary);
}
return BROTLI_TRUE;
}
static BROTLI_BOOL DecompressFile(Context* context) {
BrotliDecoderState* s = context->decoder;
BrotliDecoderResult result = BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT;View on GitHub (pinned to 1b2de5e052)
Solutions
- Increase available memory: raise container/cgroup limits or add swap.
- Reduce the number of concurrent brotli processes.
- Check and raise `ulimit -v` and `ulimit -d` if they are restrictive.
- On 32-bit, use a 64-bit build of brotli.
- Monitor system memory (`free -m`, `dmesg` for OOM-killer events) to confirm the cause.
Defensive patterns
Strategy: validation
Validate before calling
#include <sys/sysinfo.h>
#include <stdbool.h>
bool enough_memory_for_decoder(void) {
struct sysinfo si;
if (sysinfo(&si) != 0) return true;
unsigned long long freeram = (unsigned long long)si.freeram * si.mem_unit;
// Decoder state is small (tens of KB) but needs headroom under pressure
return freeram > 1 * 1024 * 1024; // at least 1 MB free
} Prevention
- Set sufficient container memory limits (at least 64 MB for brotli CLI).
- Limit the number of concurrent brotli decompression processes under memory pressure.
- Monitor for OOM-killer events in `dmesg` when running brotli in production.
When it happens
Trigger: System memory is exhausted; container memory cgroup limit reached; `ulimit -v` (virtual memory) or `ulimit -d` (data segment) set too low for the decoder's internal structures; a 32-bit build with insufficient address space under heavy load.
Common situations: Running brotli inside a tightly constrained container (e.g. Docker with `--memory=64m`); many concurrent decompression processes competing for heap; embedded system with limited RAM; CI runner under memory pressure from parallel jobs.
Related errors
- could not read dictionary: out of memory\n
- Error allocating memory for pkgDataFlags.\n
- U_MEMORY_ALLOCATION_ERROR
- U_MEMORY_ALLOCATION_ERROR
- U_MEMORY_ALLOCATION_ERROR
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/c6d38dc2479ef7a4.
Report an issue: GitHub.