Hello guys,
we are working on an application system for Windows CE which consists of several processes.
One of our devices only has 60 MB of RAM. It is divided in 8MB program storage and 52MB memory storage.
We have the following scenario:
Once our main application (and several small helper applications) is started 45 MB memory storage is in use.
That means only 7 MB are left. So far so good.
This main application gives the user the possibility to start several other tasks. Each task is another process.
And here comes the interesting part:
When the user tries to start one task it results in an systemoutofmemory exception. I understand, that makes sense.
BUT: When I now check the memory which is in use: it is reduced to 32MB - although the same processes are running as before.
So I guess somehow the GC must have noticed that memory is about to exceed and frees several MBs.
Another interesting fact:
When the user tries to start another task it does not result in an SOFM Exception. However, when I check the memory storage: it has been reduced to 32 MB as well - although no process has thrown an exception.
So my assumption is:
In the first scenario the GC frees memory too slow for the task that is being started. The process tries to allocate memory but fails => exception.
In the second scenario the GC frees memory fast enough so that the task can get whatever it is asking for.
Is that correct? If so: Is there a possibility to get scenario 1 working as well? Maybe a way to tell the GC to free memory earlier than usually.
(I do not want to add a timer to each process that executes GC.Collect every once in a while :-))
I hope you guys understood my problem. If not, please ask.
Thank you very much,
Kevin