dotnet/runtime · error

Out of memory!

Error message

Out of memory!

What it means

Printed at src/coreclr/ilasm/asmtemplates.h:104 inside the Stack<T>::PUSH template when the growing array allocation fails. The container cannot enlarge its backing store, so the new element is silently dropped.

Solutions

  1. Increase available memory for ilasm.
  2. Reduce the complexity/size of the IL being assembled.
  3. Use a 64-bit ilasm binary.
  4. Check for upstream memory leaks that exhaust the heap first.
Defensive patterns

Strategy: validation

Validate before calling

// No public API; users cannot pre-validate template internals.
// Mitigate by sizing the host: run a 64-bit ilasm with raised ulimits.

Prevention

When it happens

Trigger: Triggered when `new T*[m_ulArrLen]` returns NULL during Stack growth (GrowBuffer returns a larger size but the heap refuses it).

Common situations: Assembling IL with a very deep/long stack of items (labels, locals), or running under tight memory limits.

Related errors


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

Appendix: source

Thrown at src/coreclr/ilasm/asmtemplates.h:104

				if(m_ulOffset)
				{
					memcpy(m_Arr,&m_Arr[m_ulOffset],m_ulCount*sizeof(T*));
					m_ulOffset = 0;
				}
				else
				{
                    m_ulArrLen = GrowBuffer(m_ulArrLen);
					T** tmp = new T*[m_ulArrLen];
					if(tmp)
					{
						if(m_Arr)
						{
							memcpy(tmp,m_Arr,m_ulCount*sizeof(T*));
							delete [] m_Arr;
						}
						m_Arr = tmp;
					}
					else fprintf(stderr,"\nOut of memory!\n");
				}
			}
			m_Arr[m_ulOffset+m_ulCount] = item;
			m_ulCount++;
		}
    };
    ULONG COUNT() { return m_ulCount; };
    T* POP()
    {
        T* ret = NULL;
        if(m_ulCount)
        {
            ret = m_Arr[m_ulOffset++];
            m_ulCount--;
        }
        return ret;
    };
    T* PEEK(ULONG idx) { return (idx < m_ulCount) ? m_Arr[m_ulOffset+idx] : NULL; };

View on GitHub (pinned to 60108ba66e)