dotnet/runtime · critical
OutOfMemory!
Error message
OutOfMemory!
What it means
The Method constructor (method.cpp:52-53) pre-allocates fixed arrays for exception handlers and endfilter offsets (`new COR_ILMETHOD_SECT_EH_CLAUSE_FAT[MAX_EXCEPTIONS]` and `new DWORD[MAX_EXCEPTIONS]`). If either allocation returns NULL, ilasm prints OutOfMemory and returns, leaving the method unable to track exceptions. This is the method-level analogue of error 220.
Source
Thrown at src/coreclr/ilasm/method.cpp:56
m_FirstDocument = NULL;
m_HasMultipleDocuments = FALSE;
// move the PInvoke descriptor (if any) from Assembler
// (Assembler gets the descriptor BEFORE it calls new Method)
m_pPInvoke = pAssembler->m_pPInvoke;
pAssembler->m_pPInvoke = NULL;
_ASSERTE(pszName);
if (!pszName) return;
m_szName = pszName;
m_dwName = (DWORD)strlen(pszName);
m_ExceptionList = new COR_ILMETHOD_SECT_EH_CLAUSE_FAT[MAX_EXCEPTIONS];
m_EndfilterOffsetList = new DWORD[MAX_EXCEPTIONS];
if((m_ExceptionList==NULL)||(m_EndfilterOffsetList==NULL))
{
fprintf(stderr,"\nOutOfMemory!\n");
return;
}
m_dwMaxNumExceptions = MAX_EXCEPTIONS;
m_dwMaxNumEndfilters = MAX_EXCEPTIONS;
m_Attr = Attr;
if((!strcmp(pszName,COR_CCTOR_METHOD_NAME))||(!strcmp(pszName,COR_CTOR_METHOD_NAME)))
m_Attr |= mdSpecialName;
m_fEntryPoint = FALSE;
m_fGlobalMethod = FALSE;
if(pbsSig)
{
m_dwMethodCSig = pbsSig->length();
m_pMethodSig = (COR_SIGNATURE*)(pbsSig->ptr());
m_pbsMethodSig = pbsSig;
}
View on GitHub (pinned to 290d5ab72c)
Solutions
- Free memory on the host or move to a 64-bit ilasm build.
- Reduce the size of the assembly (fewer methods / split modules).
- Increase the container/CI memory limit.
Example fix
// before: single huge assembly with tens of thousands of methods ilasm /out=huge.dll huge.il # OutOfMemory! // after: split into smaller modules then merge ilasm /out=part1.dll part1.il
Defensive patterns
Strategy: validation
Validate before calling
// Warn before assembling if the module has an extreme method count
// (each Method pre-allocates two fixed arrays).
if (methodCount > 100000) warn('Large method count; ilasm may hit per-method OOM on low-RAM hosts'); Prevention
- Use 64-bit ilasm for large assemblies.
- Split very large assemblies into modules.
- Provision adequate memory in CI runners.
When it happens
Trigger: Assembling a file while the process is under severe memory pressure; an extremely large number of methods causing many simultaneous allocations.
Common situations: CI with tight memory limits; assembling a machine-generated assembly with many methods on a 32-bit build.
Related errors
- Out of memory!
- Out of memory!
- Out of memory in Indx256::IndexString!
- Out of memory!
- .NET runtime has failed to start, because too much memory wa
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/175748056d58b5cf.
Report an issue: GitHub.