{"record":{"id":"51b32158aaba0761","repo":"dotnet/runtime","slug":"out-of-memory-51b321","errorCode":null,"errorMessage":"\nOut of memory!\n","messagePattern":"\nOut of memory!\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coreclr/ilasm/asmman.cpp","lineNumber":43,"sourceCode":"        if(tmp)\n        {\n            WCHAR*  wz = (WCHAR*)(tmp->getBuff(L));\n            if(wz)\n            {\n                memset(wz,0,L);\n                MultiByteToWideChar(g_uCodePage,0,pb,-1,wz,l);\n                tmp->remove(L-(DWORD)u16_strlen(wz)*sizeof(WCHAR));\n#if BIGENDIAN\n                if (Swap)\n                    SwapStringLength(wz, (DWORD)u16_strlen(wz));\n#endif\n                delete pSource;\n            }\n            else\n            {\n                delete tmp;\n                tmp = NULL;\n                fprintf(stderr,\"\\nOut of memory!\\n\");\n            }\n        }\n        else\n            fprintf(stderr,\"\\nOut of memory!\\n\");\n        return tmp;\n    }\n    return NULL;\n}\n\nAsmManFile*         AsmMan::GetFileByName(_In_ __nullterminated char* szFileName)\n{\n    AsmManFile* ret = NULL;\n    if(szFileName)\n    {\n        //AsmManFile X;\n        //X.szName = szFileName;\n        //ret = m_FileLst.FIND(&X);\n        //X.szName = NULL;","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/ilasm/asmman.cpp#L25-L61","documentation":"Printed at src/coreclr/ilasm/asmman.cpp:43 when BinStrToUnicode fails to allocate the WCHAR buffer (getBuff returns NULL) during conversion of a byte string to Unicode. ilasm continues with a NULL result, which typically surfaces later as a different failure.","triggerScenarios":"Triggered inside BinStrToUnicode when `tmp->getBuff(L)` returns NULL because the heap cannot satisfy the allocation (L = 2 * source length bytes).","commonSituations":"Assembling a very large manifest/string blob, running ilasm in a memory-constrained container, or hitting OS allocation limits.","solutions":["Increase available memory / raise ulimit for the ilasm process.","Split the input into smaller assemblies if the blob is huge.","On Windows, allow the 64-bit ilasm to address more memory.","Free other processes from the host to reduce memory pressure."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before assembling very large blobs, check available address space\n#include <sys/resource.h>\nbool enough_memory(size_t needed) {\n    struct rlimit rl; getrlimit(RLIMIT_AS,&rl);\n    return rl.rlim_cur == RLIM_INFINITY || rl.rlim_cur > needed;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Raise ulimit / run 64-bit ilasm for large inputs.","Split huge manifests into smaller assemblies.","Free other memory-hungry processes on the host."],"tags":["coreclr","ilasm","out-of-memory","allocation"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}