What does the COINIT_SPEED_OVER_MEMORY flag to CoInitializeEx do?
One of the flags you can pass to
COINIT_SPEED_OVER_MEMORY, which is documented as
COINIT_SPEED_OVER_MEMORY: Trade memory for speed.
This documentation is already vague since it doesn’t say which direction the trade is being made. Are you reducing memory to increase speed, or increasing memory by reducing speed? Actually it’s neither: If you pass this flag, then you are instructing COM to consume more memory in an attempt to reduce CPU usage, under the assumption that you run faster by executing fewer cycles.¹ The request is a per-process one-way transition. Once anybody anywhere in the process puts COM into speed-over-memory mode, the flag stays set and remains set until the process exits. When should you enable this mode? It doesn’t matter, because as far as I can tell, there is no code anywhere in COM that changes its behavior based on whether the process has been placed into this mode! It looks like the flag was added when DCOM was introduced, but it never got hooked up to anything. (Or whatever code that had been hooked up to it never shipped.)
¹ As you know, consuming more memory is not a guarantee that you will actually run faster, because higher memory usage increases the chances that what you need will take an L1 cache miss or a page fault, which will cost you dearly in wait time (though not in CPU usage).