nodejs/node · critical
U_MEMORY_ALLOCATION_ERROR
U_MEMORY_ALLOCATION_ERROR
Error message
icupkg: malloc error allocating %d bytes.\n
What it means
Thrown by readFile() when uprv_malloc() returns NULL while allocating a buffer for reading a data file. The allocation size is the file length padded up to a multiple of 16 bytes. This indicates the system cannot satisfy the memory request.
Source
Thrown at deps/icu-small/source/tools/toolutil/package.cpp:334
if(file==nullptr) {
fprintf(stderr, "icupkg: unable to open input file \"%s\"\n", filename);
exit(U_FILE_ACCESS_ERROR);
}
/* get the file length */
fileLength=getFileLength(file);
if(ferror(file) || fileLength<=0) {
fprintf(stderr, "icupkg: empty input file \"%s\"\n", filename);
fclose(file);
exit(U_FILE_ACCESS_ERROR);
}
/* allocate the buffer, pad to multiple of 16 */
length=(fileLength+0xf)&~0xf;
icu::LocalMemory<uint8_t> data(static_cast<uint8_t*>(uprv_malloc(length)));
if(data.isNull()) {
fclose(file);
fprintf(stderr, "icupkg: malloc error allocating %d bytes.\n", static_cast<int>(length));
exit(U_MEMORY_ALLOCATION_ERROR);
}
/* read the file */
if (fileLength != static_cast<int32_t>(fread(data.getAlias(), 1, fileLength, file))) {
fprintf(stderr, "icupkg: error reading \"%s\"\n", filename);
fclose(file);
exit(U_FILE_ACCESS_ERROR);
}
/* pad the file to a multiple of 16 using the usual padding byte */
if(fileLength<length) {
memset(data.getAlias()+fileLength, 0xaa, length-fileLength);
}
fclose(file);
// minimum check for ICU-format dataView on GitHub (pinned to 1b2de5e052)
Solutions
- Check available memory: free -h and ulimit -v.
- If running in a container, increase the memory limit.
- Reduce the data file size by trimming unnecessary locales with icupkg -r before processing.
- Build with a 64-bit toolchain if currently 32-bit.
Defensive patterns
Strategy: validation
Validate before calling
// Check available memory and file size before processing
#include <sys/stat.h>
#include <sys/resource.h>
bool canAllocateForFile(const char* filename) {
struct stat st;
if (stat(filename, &st) != 0) return false;
size_t needed = (st.st_size + 0xf) & ~0xf; // pad to 16
struct rlimit rl;
if (getrlimit(RLIMIT_AS, &rl) == 0 && rl.rlim_cur != RLIM_INFINITY) {
return needed < rl.rlim_cur / 4; // conservative heuristic
}
return true;
} Prevention
- Monitor memory usage in CI and build containers.
- Set appropriate container memory limits higher than the largest expected .dat file.
- Use 64-bit builds for large data packages.
- Trim unnecessary locales with icupkg -r to reduce data size.
When it happens
Trigger: Reading a data file whose padded length causes uprv_malloc() to fail. This can happen with very large data files, or when system memory is exhausted. The padded length is (fileLength + 0xf) & ~0xf.
Common situations: Very large ICU data files that exceed available virtual memory; process memory limits (ulimit -v) in CI environments; containers with low memory cgroup limits; 32-bit processes with limited address space; memory fragmentation after many allocations.
Related errors
- U_MEMORY_ALLOCATION_ERROR
- Error allocating memory for pkgDataFlags.\n
- out of memory\n
- U_MEMORY_ALLOCATION_ERROR
- U_MEMORY_ALLOCATION_ERROR
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/f9bbf2c7e9b94178.
Report an issue: GitHub.