by jasper » 10 August 2014, 09:29
To answer your question about the second CoCreateInstance: by default COFE does not solve in the main thread. It solves in a background thread. As COFE uses the apartment threaded model, it cannot use the unit operations from the main thread in the solution thread. Therefore, it saves the one in the main thread, creates a new one in the solution thread, and restores it from the saved one. Now there are two copies; one in the main thread and one in the solution thread.
You can turn this off (in preferences you can untick the box to use a separate thread for solutions) but now solving is done in the main thread, which makes the application respond less. More-over, this is the calling pattern to be expected in any multi-threaded CAPE-OPEN application. See here for more info: