I am reprogramming a C # application to run on Windows CE, however, my machine has little memory. Therefore, I need to allocate the appropriate amount of program memory and storage memory. I can not allocate this manually at every reboot, so I found the SetSystemMemoryDivision () function. 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 every time I reboot the machine and try to run the program, the system hangs.
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.