{"record":{"id":"f7f1e9840e49ecc2","repo":"nodejs/node","slug":"u-memory-allocation-error-f7f1e9","errorCode":"U_MEMORY_ALLOCATION_ERROR","errorMessage":"memory allocation (%ld bytes) for file contents failed","messagePattern":"memory allocation \\(%ld bytes\\) for file contents failed","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"deps/icu-small/source/tools/genrb/parse.cpp","lineNumber":1331,"sourceCode":"    }\n    if (state->icu4xMode) {\n        char *nameWithoutSuffix = static_cast<char *>(uprv_malloc(uprv_strlen(state->filename) + 1));\n        if (nameWithoutSuffix == nullptr) {\n            *status = U_MEMORY_ALLOCATION_ERROR;\n            res_close(result);\n            return nullptr;\n        }\n        uprv_strcpy(nameWithoutSuffix, state->filename);\n        *uprv_strrchr(nameWithoutSuffix, '.') = 0;\n\n        writeCollationTOML(state->outputdir, nameWithoutSuffix, collationType, t->data, t->settings, status);\n        uprv_free(nameWithoutSuffix);\n    }\n    icu::LocalMemory<uint8_t> buffer;\n    int32_t capacity = 100000;\n    uint8_t *dest = buffer.allocateInsteadAndCopy(capacity);\n    if(dest == nullptr) {\n        fprintf(stderr, \"memory allocation (%ld bytes) for file contents failed\\n\",\n                static_cast<long>(capacity));\n        *status = U_MEMORY_ALLOCATION_ERROR;\n        res_close(result);\n        return nullptr;\n    }\n    int32_t indexes[icu::CollationDataReader::IX_TOTAL_SIZE + 1];\n    int32_t totalSize = icu::CollationDataWriter::writeTailoring(\n            *t, *t->settings, indexes, dest, capacity, intStatus);\n    if(intStatus == U_BUFFER_OVERFLOW_ERROR) {\n        intStatus = U_ZERO_ERROR;\n        capacity = totalSize;\n        dest = buffer.allocateInsteadAndCopy(capacity);\n        if(dest == nullptr) {\n            fprintf(stderr, \"memory allocation (%ld bytes) for file contents failed\\n\",\n                    static_cast<long>(capacity));\n            *status = U_MEMORY_ALLOCATION_ERROR;\n            res_close(result);\n            return nullptr;","sourceCodeStart":1313,"sourceCodeEnd":1349,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/genrb/parse.cpp#L1313-L1349","documentation":"While writing collation tailoring data, genrb allocates an initial 100,000-byte buffer via LocalMemory<uint8_t>::allocateInsteadAndCopy(). If this allocation returns null (system malloc failed), the tool sets U_MEMORY_ALLOCATION_ERROR. This is the initial buffer for CollationDataWriter::writeTailoring output before the actual size is known.","triggerScenarios":"System out of memory at the point of the initial 100KB buffer allocation. This is a small allocation failing, which means the process or system is under extreme memory pressure — not a size-dependent failure. Can also occur if the process has hit a ulimit or container memory cgroup limit.","commonSituations":"Running genrb in a memory-constrained container (Docker cgroup limit); parallel genrb processes consuming all available RAM; a system with swap disabled under heavy load; a memory leak in a previous processing step exhausting the address space.","solutions":["Check system memory: `free -h` and `dmesg | grep -i 'out of memory'`","Reduce parallelism in the build (fewer concurrent genrb processes)","Increase the container's memory limit if running under Docker/Kubernetes","Check process ulimits: `ulimit -v` and `ulimit -m`","Close other memory-intensive applications during the build"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Check memory availability before running genrb builds\n# Ensure at least 500MB free for typical genrb processing\nfree_mb=$(free -m | awk '/^Mem:/ {print $7}')\n[ \"$free_mb\" -gt 500 ] || { echo \"WARNING: only ${free_mb}MB available\"; }\n# Check container limits if applicable\ncat /sys/fs/cgroup/memory/memory.limit_in_bytes 2>/dev/null || echo \"No cgroup memory limit\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Monitor system memory before and during large ICU data builds","Limit build parallelism (e.g. make -j2 instead of make -j8) when memory is constrained","Set appropriate container memory limits in Docker/Kubernetes","Build large locale sets in batches to avoid peak memory pressure"],"tags":["icu","genrb","memory","oom","collation"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}