views:

885

answers:

3

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?

A: 

How much virtual memory is allocated? Try increasing the value if possible.

nitroxn
I'm not sure I know what you mean, is this relating to the memory settings that deltreme mentioned?
Grant Crofton
Virtual Memory is not adjustable in any version of CE.
ctacke
A: 

I don't know if this also applies for MC75, but on Start->Settings->Control Panel->System there should be a Memory tab, where you can adjust how much memory is available as RAM, and how much is reserved for storing files.

This does not apply to the \Permanent Storage folder (or \Storage Card, as it's called on our device), but to the other folders, like \Temp.

deltreme
There is a memory page, but you can't adjust it - from what I understand, this is no longer possible in WM6 as the two memories are logically (maybe even physically) separate. And without knowing which memory the problem was with I wouldn't know which way to adjust it anyway!
Grant Crofton
+2  A: 

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'm 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.

Hans Passant
Thanks, that's useful. Although it looks like ERROR_NOT_ENOUGH_MEMORY is for the message 'Not enough storage is available to process this command'. The message 'Not enough storage is available to complete this operation' (which I'm getting) is for code 14, ERROR_OUTOFMEMORY, according to the following page:http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspxAlthough I can't find what the difference between those two codes is. Do you know, does your answer still apply to error code 14?In the meantime I'll check out those 'using' statements...
Grant Crofton
Yes, I think so. Got the wrong one, that looks like a DDE error.
Hans Passant