dotnet/runtime · critical
Out of memory!
Error message
Out of memory!
What it means
ilasm failed to allocate the byte buffer that backs a serialized custom-attribute / security-declaration blob. In Assembler (assembler.h:495) the blob size `bytes` is computed from the number of name/value pairs and their string lengths, then `m_Blob = new BYTE[bytes]` is attempted; when the allocator returns NULL (nothrow), ilasm prints this message and returns from the constructor, leaving the blob un-built. It indicates the process ran out of address space or the computed size was pathologically large.
Source
Thrown at src/coreclr/ilasm/assembler.h:498
bytes += 4;
break;
case SERIALIZATION_TYPE_STRING:
length = (int)strlen((const char *)&pVal[1]);
bytes += CPackedLen::Size(length) + length;
break;
case SERIALIZATION_TYPE_ENUM:
length = (int)strlen((const char *)&pVal[1]);
bytes += CPackedLen::Size((ULONG)length) + length;
bytes += 4;
break;
}
p = p->Next();
}
m_Blob = new BYTE[bytes];
if(m_Blob==NULL)
{
fprintf(stderr,"\nOut of memory!\n");
return;
}
m_Blob[0] = 0x01; // Version
m_Blob[1] = 0x00;
m_Blob[2] = (BYTE)action; // Constructor arg (security action code)
m_Blob[3] = 0x00;
m_Blob[4] = 0x00;
m_Blob[5] = 0x00;
m_Blob[6] = (BYTE)count; // Property/field count
m_Blob[7] = (BYTE)(count >> 8);
for (i = 0, pBlob = &m_Blob[8], p = pairs; i < count; i++, p = p->Next()) {
BYTE *pVal = (BYTE*)p->Value()->ptr();
char *szType;
// Set field/property setter type.
*pBlob++ = SERIALIZATION_TYPE_PROPERTY;View on GitHub (pinned to 290d5ab72c)
Solutions
- Reduce the number/size of custom attributes and security declarations in the IL source being assembled.
- Re-run ilasm on a machine with more free memory, or close other large processes first.
- Use the 64-bit (amd64/arm64) build of ilasm so the process has a larger address space.
- Split the assembly into smaller modules and merge with ILMerge/al instead of one huge file.
Example fix
// before: thousands of permission pairs fed into one declaration .permissionset assert = (n many long strings ...) // after: trim to only the permissions actually required .permissionset assert = (fewer, shorter entries ...)
Defensive patterns
Strategy: validation
Validate before calling
// Before invoking ilasm, sanity-check attribute counts in generated IL.
// (Pseudo) warn if a single type declares > N custom-attribute/security pairs.
if (maxAttributePairsPerType > 1024) {
warn("IL declares %zu attribute pairs; risk of OOM in blob alloc", maxAttributePairsPerType);
} Prevention
- Run the 64-bit ilasm to maximize address space.
- Cap attribute/security-declaration counts in IL generators.
- Monitor ilasm RSS in CI and fail early on memory growth.
When it happens
Trigger: Assembling IL that declares an extremely large set of custom attributes or security permission sets (many named fields / long string values); running ilasm on a machine under heavy memory pressure or a 32-bit build near the 2-4GB ceiling.
Common situations: CI agents with low memory limits; a script/IL-generator that emits thousands of attribute pairs; a 32-bit ilasm binary assembling a huge generated assembly.
Related errors
- Out of memory!
- Out of memory!
- Out of memory in Indx256::IndexString!
- OutOfMemory!
- .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/e5d72d216750f9ec.
Report an issue: GitHub.