Not enough storage is available to complete this operation - Program or Storage memory?

Grant Crofton picture Grant Crofton · May 21, 2010 · Viewed 21.9k times · Source

I've been given a Windows Mobile app written in .Net CF 3.5 to fix, and one of the problems is to do with storage.

The message 'Not enough storage is available to complete this operation' has appeared a few times - it's logged in the SQL CE database, and always happens during data access (but not the same bit of data access).

The thing I'm slightly confused about is whether this refers to Program Memory (e.g. RAM) or Storage Memory (e..g permanent storage). It would appear to be storage memory, but the devices seem to have plenty free. While there are some OutOfMemoryExceptions, these appear totally unrelated to this problem (in that that happen at a different time due to an image-related issue).

We're using SQL CE 3.5 with a single connection, which is stored along with the app on the device (as opposed to the storage card). The device is a Motorola MC75 running Windows Mobile 6.1.

Any thoughts?

Answer

Hans Passant picture Hans Passant · May 21, 2010

It is a low-level Windows error, code 14, ERROR_OUTOFMEMORY. The error message doesn't mention "memory" because it isn't always caused by running out of memory. The most typical trigger is a program exceeding its quota of kernel resources. Like 10,000 window handles, there are many others. That's for the desktop edition btw, I don't doubt it is much lower on Windows Mobile.

Well, the program is a piggy. One possible way to trigger this error is to not call Dispose() on objects of classes that implement IDisposable. That will consume kernel resources that won't be released until the garbage collector and finalizer thread run. Which could take a while. The SQL CE classes are certainly a candidate. If you have no clue where the resource leak or over-usage is coming from then invest in a profiler that works on CF.