6
I am reprogramming a C# application to run on Windows CE, but my machine has little memory.
Therefore, I need to allocate the appropriate amount of processing memory (program memory) and storage memory (Storage memory). I can’t manually allocate this to each reboot, so I found the function Setsystemmemorydivision().
The code to allocate memory is basically the following:
//Confere se a memória está alocada corretamente
while (storage_page != 800)
{
//Seta a memória para 800 pages de 4096 bytes cada (4Kb * 800 = 3.200Kb)
storage_page = 800;
//Grava a memória setada
SetSystemMemoryDivision(storage_page);
Thread.Sleep(200);
//Lê a memória do sistema
GetSystemMemoryDivision(ref storage_page, ref ram_page, ref page_size);
}
chamamenu();
The function is working in debug mode, but whenever I restart the machine and try to run the program, the system crashes.
How can I ensure that the memory has been allocated before running any other process that might lock the machine? It is possible that the application is allocating more than the 32mb available for RAM.
In the MSDN says that this function was "deprecated" and should not be used.
– dcastro
Thank you, dcastro. Unfortunately all Windows CE is obsolete, but it is still the default environment for this application. Some function has replaced the old one or Microsoft simply thinks that we no longer need to manage the memories?
– Raul de Macedo