nodejs/node · critical

U_MEMORY_ALLOCATION_ERROR

U_MEMORY_ALLOCATION_ERROR

Error message

Could not allocate memory!!

What it means

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.

Source

Thrown at deps/icu-small/source/tools/genrb/wrtxml.cpp:411

        break;

    }
    *len = i+1;
}

static void
print(char16_t* src, int32_t srcLen,const char *tagStart,const char *tagEnd,  UErrorCode *status){
    int32_t bufCapacity   = srcLen*4;
    char *buf       = nullptr;
    int32_t bufLen = 0;

    if(U_FAILURE(*status)){
        return;
    }

    buf = static_cast<char*>(uprv_malloc(bufCapacity));
    if (buf == nullptr) {
        fprintf(stderr, "Could not allocate memory!!");
        exit(U_MEMORY_ALLOCATION_ERROR);
    }
    buf = convertAndEscape(&buf, bufCapacity, &bufLen, src, srcLen,status);
    if(U_SUCCESS(*status)){
        trim(&buf,&bufLen);
        write_utf8_file(out,UnicodeString(tagStart));
        write_utf8_file(out,UnicodeString(buf, bufLen, "UTF-8"));
        write_utf8_file(out,UnicodeString(tagEnd));
        write_utf8_file(out,UnicodeString("\n"));

    }
}
#endif

static void
printNoteElements(const UString *src, UErrorCode *status){

#if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpressions are available */

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Check available system memory: `free -h`
  2. Reduce build parallelism to lower peak memory usage
  3. Increase container memory limits if applicable
  4. Investigate whether any string in the resource bundle is unexpectedly large (may indicate data corruption or accidental inclusion of a large file)
  5. Split large resource bundles into smaller per-locale files to reduce per-process peak memory
Defensive patterns

Strategy: validation

Validate before calling

# Check available memory and string sizes before XLIFF build
free -h
# Find resource bundles with very large strings (potential memory issue for XLIFF output)
for f in data/*.txt; do
    size=$(wc -c < "$f")
    [ "$size" -gt 1000000 ] && echo "Large bundle file: $f ($size bytes)"
done

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/fdd0fd9e14a290ed. Report an issue: GitHub.