Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Troubleshooting ERROR_NOT_ENOUGH_MEMORY

Our application is failing on one specific user's computer with ERROR_NOT_ENOUGH_MEMORY ("Not enough storage is available to process this command").

The error is apparently being raised somewhere deep within the Delphi VCL framework that we're using, so I'm not sure which Windows API function is responsible.

Is memory a problem? A call to GlobalMemoryStatus gives the following information:

  • dwTotalPhys - 1063150000 (~1 GB)
  • dwAvailPhys - 26735000 (~27 MB)
  • dwAvailPage - 1489000000 (~1.4 GB)

It seems strange to me that Windows would let the available physical memory get so low when so much space is available in the paging file, but I don't know enough about Windows' virtual memory management to know if this is normal or not. Is it?

If not memory, then which resource limit is being hit? From what I read online, ERROR_NOT_ENOUGH_MEMORY could be the result of the application hitting any of several limits (GDI objects, USER objects, handles, etc.) and not necessarily memory. Is there a comprehensive list of what limits Windows enforces? Is there any way to find out which limit is being hit? I tried Google, but I couldn't find any systematic overview.

like image 618
Josh Kelley Avatar asked Sep 21 '09 14:09

Josh Kelley


1 Answers

A more common cause this error than any of those you've listed is fragmentation of Virtual Memory Space. This a situation where whilst the total free memory is quite reasonable the free space is fragmented with various bits of the virtual memory space being currently allocated. Hence you can get an out of memory error when a request for memory cannot be satisfied by a single contiguous block despite the being enough in total free.

like image 197
AnthonyWJones Avatar answered Sep 30 '22 21:09

AnthonyWJones