Delphi / Object Pascal · Exception

EOutOfMemory Exception

What does EOutOfMemory Exception mean in Delphi / Object Pascal?

Raised when the application asks the memory manager for dynamic memory and there isn't enough free memory left to satisfy the request. Memory for the exception object itself is pre-allocated at startup so it can always be raised and reported even when the heap is exhausted. It surfaces under sustained memory leaks, unbounded collection growth, or when a 32-bit process approaches its address-space limit.

EOutOfMemory ExceptionDelphi (VCL) · Delphi (FireMonkey)

Condition

Raised when the application asks the memory manager for dynamic memory and there isn't enough free memory left to satisfy the request. Memory for the exception object itself is pre-allocated at startup so it can always be raised and reported even when the heap is exhausted. It surfaces under sustained memory leaks, unbounded collection growth, or when a 32-bit process approaches its address-space limit.

Fix

Never construct EOutOfMemory directly - call the OutOfMemoryError procedure so the pre-reserved instance is used. Profile with FastMM4's leak reporting to find the growth source, free large buffers and collections promptly, and consider a 64-bit build if the process is hitting the 32-bit address ceiling.

Related exception