Flush with care

I would like to add some comments to extend what was said on a recent post on the Windows Mobile blog. It says that developers can use RegFlushKey to make sure their registry data persists, but that legacy applications will be okay because we’ve built some persistence into the OS. I actually try to go further and discourage application developers from calling RegFlushKey!

Just like a file system cache, the registry persistence is NOT, repeat NOT supposed to be the responsibility of the application developer. They should be able to modify the registry however they want without sparing a thought for persistence. If applications get into the habit of calling RegFlushKey, they are only contributing to performance problems.

Instead it is up to us (the Windows CE and Windows Mobile teams) as well as up to the OEM to solve the persistence problem. We’ve put registry flushing into a few important places in the OS, and wrote an optional flush thread that OEMs can choose to enable. If you are an OEM, then okay, call RegFlushKey in a way that makes sense for your device. Or enable our registry flush thread. But if you’re writing an application, use it with care so as not to negatively impact performance.