{"record":{"id":"c6d38dc2479ef7a4","repo":"nodejs/node","slug":"out-of-memory-n","errorCode":null,"errorMessage":"out of memory\\n","messagePattern":"out of memory\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":1201,"sourceCode":"      if (context->comment_pos >= context->comment_len) {\n        context->comment_state = COMMENT_BAD;\n        return;\n      }\n      if (context->comment[context->comment_pos++] != data[i]) {\n        context->comment_state = COMMENT_BAD;\n        return;\n      }\n    }\n    if (context->comment_pos == context->comment_len) {\n      context->comment_state = COMMENT_OK;\n    }\n  }\n}\n\nstatic BROTLI_BOOL InitDecoder(Context* context) {\n  context->decoder = BrotliDecoderCreateInstance(NULL, NULL, NULL);\n  if (!context->decoder) {\n    fprintf(stderr, \"out of memory\\n\");\n    return BROTLI_FALSE;\n  }\n  /* This allows decoding \"large-window\" streams. Though it creates\n      fragmentation (new builds decode streams that old builds don't),\n      it is better from used experience perspective. */\n  BrotliDecoderSetParameter(\n      context->decoder, BROTLI_DECODER_PARAM_LARGE_WINDOW, 1u);\n  if (context->dictionary) {\n    BrotliDecoderAttachDictionary(context->decoder,\n        BROTLI_SHARED_DICTIONARY_RAW, context->dictionary_size,\n        context->dictionary);\n  }\n  return BROTLI_TRUE;\n}\n\nstatic BROTLI_BOOL DecompressFile(Context* context) {\n  BrotliDecoderState* s = context->decoder;\n  BrotliDecoderResult result = BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT;","sourceCodeStart":1183,"sourceCodeEnd":1219,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L1183-L1219","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#include <sys/sysinfo.h>\n#include <stdbool.h>\n\nbool enough_memory_for_decoder(void) {\n    struct sysinfo si;\n    if (sysinfo(&si) != 0) return true;\n    unsigned long long freeram = (unsigned long long)si.freeram * si.mem_unit;\n    // Decoder state is small (tens of KB) but needs headroom under pressure\n    return freeram > 1 * 1024 * 1024; // at least 1 MB free\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["memory","allocation","decoder","oom","brotli"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}