How to allocate program memory and storage before running my application in WinCE?

6

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.

    
asked by anonymous 11.02.2014 / 17:49

2 answers

2

Problem solved.

The main problem was with the GC of GC 2.0, which was not managing the collection correctly. With an upgrade from .NET CF v2.0 to v3.5 on both machine and project, the GC started to manage collection correctly and the application worked perfectly.

Thanks to everyone who tried to help and I hope I have helped someone with similar problems.

    
20.02.2014 / 12:58
0

I do not know much about Windows CE, but if you need a larger amount of memory, use virtual memory. link

If using .NET ready imports does not work, use P / Invoke. link

    
17.02.2014 / 17:33