{"record":{"id":"fdd0fd9e14a290ed","repo":"nodejs/node","slug":"u-memory-allocation-error-fdd0fd","errorCode":"U_MEMORY_ALLOCATION_ERROR","errorMessage":"Could not allocate memory!!","messagePattern":"Could not allocate memory!!","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"deps/icu-small/source/tools/genrb/wrtxml.cpp","lineNumber":411,"sourceCode":"        break;\n\n    }\n    *len = i+1;\n}\n\nstatic void\nprint(char16_t* src, int32_t srcLen,const char *tagStart,const char *tagEnd,  UErrorCode *status){\n    int32_t bufCapacity   = srcLen*4;\n    char *buf       = nullptr;\n    int32_t bufLen = 0;\n\n    if(U_FAILURE(*status)){\n        return;\n    }\n\n    buf = static_cast<char*>(uprv_malloc(bufCapacity));\n    if (buf == nullptr) {\n        fprintf(stderr, \"Could not allocate memory!!\");\n        exit(U_MEMORY_ALLOCATION_ERROR);\n    }\n    buf = convertAndEscape(&buf, bufCapacity, &bufLen, src, srcLen,status);\n    if(U_SUCCESS(*status)){\n        trim(&buf,&bufLen);\n        write_utf8_file(out,UnicodeString(tagStart));\n        write_utf8_file(out,UnicodeString(buf, bufLen, \"UTF-8\"));\n        write_utf8_file(out,UnicodeString(tagEnd));\n        write_utf8_file(out,UnicodeString(\"\\n\"));\n\n    }\n}\n#endif\n\nstatic void\nprintNoteElements(const UString *src, UErrorCode *status){\n\n#if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpressions are available */","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/genrb/wrtxml.cpp#L393-L429","documentation":"In the XLIFF output path's print() function, genrb calls uprv_malloc() to allocate a buffer of srcLen*4 bytes (worst-case for UTF-16 to UTF-8 expansion plus XML escaping). If malloc returns null, the tool immediately exits the process with U_MEMORY_ALLOCATION_ERROR. This is an unconditional process exit, not a recoverable error.","triggerScenarios":"System memory exhaustion at the point of allocating the XML output buffer. The buffer size is proportional to the source string length times 4. A very long string or a system under memory pressure can trigger this. Since the tool calls exit(), no cleanup or recovery is possible.","commonSituations":"Processing a resource bundle with extremely long string values (megabytes of text); system under memory pressure from parallel genrb processes; container with tight memory limits; memory fragmentation after processing many large bundles.","solutions":["Check available system memory: `free -h`","Reduce build parallelism to lower peak memory usage","Increase container memory limits if applicable","Investigate whether any string in the resource bundle is unexpectedly large (may indicate data corruption or accidental inclusion of a large file)","Split large resource bundles into smaller per-locale files to reduce per-process peak memory"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Check available memory and string sizes before XLIFF build\nfree -h\n# Find resource bundles with very large strings (potential memory issue for XLIFF output)\nfor f in data/*.txt; do\n    size=$(wc -c < \"$f\")\n    [ \"$size\" -gt 1000000 ] && echo \"Large bundle file: $f ($size bytes)\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure sufficient system memory before running genrb with --write-xliff on large bundles","Split resource bundles with very large strings into smaller files","Monitor memory usage during XLIFF generation builds","Reduce build parallelism for XLIFF output to lower peak memory"],"tags":["icu","genrb","memory","oom","xliff","xml"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}