Why are my programs running from my SD card so slow?
When moving my .Net Compact Framework application to the SD-card of a Windows CE device, the program executes slower then running it from the internal memory.
I thought, the start-up might be slower, but it is the whole program. There is no IO to the storage card.
Why is my application so slow and how does the compact framework handles and loads the assemblies?
It has to do with demand-paging. Your app cannot be run directly from the SD-card, as SD is not executable media so it has to be pulled into RAM to run. Windows CE doesn't typically have a whole lot of RAM, so the loader doesn't pull your entire application into RAM to run. Sure, your heaps and stacks will be in RAM, but the actual IL code in the assembly itself is paged in as needed. It's also paged out when the system decides it no longer needs a specific page.
This paging can have an impact on performance, though I'm a bit surprised that it's a large impact unless the app itself is really large (like if you have lots of embedded resources that it's pulling out of the assembly).
I agree with the previous "demand-paging" answer by ctacke.
A solution you might try is to execute a loader program from the SD-card that copies your actual executable and DLLs from card to hard disk, and then execute your program from the loader. In subsequent executions the loader can detect if the hard disk version is up to date, and if so just launch it directly. If the hard disk version is not up to date, the loader will again copy out-of-date files from card and then execute the actual program.
I have done this before from a program loaded at a remote network location, and it worked very well.
Some device will crash your program if application is on sd-card. It happens while suspend-power-on device.