dotnet/runtime · error

Out of memory!

Error message

Out of memory!

What it means

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.

Solutions

  1. Increase available memory / raise ulimit for the ilasm process.
  2. Split the input into smaller assemblies if the blob is huge.
  3. On Windows, allow the 64-bit ilasm to address more memory.
  4. Free other processes from the host to reduce memory pressure.
Defensive patterns

Strategy: validation

Validate before calling

// Before assembling very large blobs, check available address space
#include <sys/resource.h>
bool enough_memory(size_t needed) {
    struct rlimit rl; getrlimit(RLIMIT_AS,&rl);
    return rl.rlim_cur == RLIM_INFINITY || rl.rlim_cur > needed;
}

Prevention

When it happens

Trigger: Triggered inside BinStrToUnicode when `tmp->getBuff(L)` returns NULL because the heap cannot satisfy the allocation (L = 2 * source length bytes).

Common situations: Assembling a very large manifest/string blob, running ilasm in a memory-constrained container, or hitting OS allocation limits.

Related errors


AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10). Data as JSON: /api/errors/51b32158aaba0761. Report an issue: GitHub.

Appendix: source

Thrown at src/coreclr/ilasm/asmman.cpp:43

        if(tmp)
        {
            WCHAR*  wz = (WCHAR*)(tmp->getBuff(L));
            if(wz)
            {
                memset(wz,0,L);
                MultiByteToWideChar(g_uCodePage,0,pb,-1,wz,l);
                tmp->remove(L-(DWORD)u16_strlen(wz)*sizeof(WCHAR));
#if BIGENDIAN
                if (Swap)
                    SwapStringLength(wz, (DWORD)u16_strlen(wz));
#endif
                delete pSource;
            }
            else
            {
                delete tmp;
                tmp = NULL;
                fprintf(stderr,"\nOut of memory!\n");
            }
        }
        else
            fprintf(stderr,"\nOut of memory!\n");
        return tmp;
    }
    return NULL;
}

AsmManFile*         AsmMan::GetFileByName(_In_ __nullterminated char* szFileName)
{
    AsmManFile* ret = NULL;
    if(szFileName)
    {
        //AsmManFile X;
        //X.szName = szFileName;
        //ret = m_FileLst.FIND(&X);
        //X.szName = NULL;

View on GitHub (pinned to 60108ba66e)