{"record":{"id":"43d0f88855c8d0b9","repo":"nodejs/node","slug":"error-allocating-memory-for-pkgdataflags-n","errorCode":null,"errorMessage":"Error allocating memory for pkgDataFlags.\\n","messagePattern":"Error allocating memory for pkgDataFlags\\.\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"deps/icu-small/source/tools/pkgdata/pkgdata.cpp","lineNumber":872,"sourceCode":"    UErrorCode status = U_ZERO_ERROR;\n    int32_t result = 0;\n    int32_t currentBufferSize = SMALL_BUFFER_MAX_SIZE;\n    int32_t tmpResult = 0;\n\n    /* Initialize pkgdataFlags */\n    pkgDataFlags = static_cast<char**>(uprv_malloc(sizeof(char*) * PKGDATA_FLAGS_SIZE));\n\n    /* If we run out of space, allocate more */\n#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)\n    do {\n#endif\n        if (pkgDataFlags != nullptr) {\n            for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) {\n                pkgDataFlags[i] = static_cast<char*>(uprv_malloc(sizeof(char) * currentBufferSize));\n                if (pkgDataFlags[i] != nullptr) {\n                    pkgDataFlags[i][0] = 0;\n                } else {\n                    fprintf(stderr,\"Error allocating memory for pkgDataFlags.\\n\");\n                    /* If an error occurs, ensure that the rest of the array is nullptr */\n                    for (int32_t n = i + 1; n < PKGDATA_FLAGS_SIZE; n++) {\n                        pkgDataFlags[n] = nullptr;\n                    }\n                    return -1;\n                }\n            }\n        } else {\n            fprintf(stderr,\"Error allocating memory for pkgDataFlags.\\n\");\n            return -1;\n        }\n\n        if (o->options == nullptr) {\n            return result;\n        }\n\n#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)\n        /* Read in options file. */","sourceCodeStart":854,"sourceCodeEnd":890,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/pkgdata/pkgdata.cpp#L854-L890","documentation":"uprv_malloc() returned nullptr when allocating the pkgDataFlags pointer array itself (sizeof(char*) * PKGDATA_FLAGS_SIZE). This is an out-of-memory condition at the very start of initializePkgDataFlags(). The tool cannot proceed without the flags array and exits with -1.","triggerScenarios":"System is severely memory-constrained when pkgdata starts up. PKGDATA_FLAGS_SIZE entries of char* could not be allocated. This is the outer allocation failing before any individual flag strings are allocated.","commonSituations":"Running pkgdata in a memory-limited container or VM; ulimit set too low; extremely large PKGDATA_FLAGS_SIZE due to a misconfigured build; system under heavy memory pressure from parallel builds.","solutions":["Free system memory or increase available memory (close other processes, increase VM/container memory).","Reduce parallelism in the build (fewer -j jobs).","Check and raise the memory ulimit: 'ulimit -v unlimited'.","If building in a container, increase its memory limit."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before running pkgdata, check available memory\n#include <sys/sysinfo.h>\n\nbool checkMemoryAvailable() {\n    struct sysinfo info;\n    if (sysinfo(&info) == 0) {\n        unsigned long avail = info.freeram * info.mem_unit;\n        return avail > (16 * 1024 * 1024);  // need at least 16MB free\n    }\n    return true; // can't check, allow attempt\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Monitor memory usage during builds; reduce -j parallelism if memory is tight.","Increase container/VM memory limits for build jobs.","Check 'ulimit -v' and raise it if necessary."],"tags":["icu","pkgdata","memory","oom","allocation","build-tool"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}