After seeing presentations that assert that “Workflow runtime is lightweight” and not finding any concrete numbers to support that claim I decided to do some of my own profiling.
Here is what I’ve done, measuring memory utilization after every step (the displayed results are the difference, in bytes, of current memory consumption minus one at the previous check point):
System.Workflow.Runtime.WorkflowRuntime wr = new System.Workflow.Runtime.WorkflowRuntime();
wr.StartRuntime();
wr.CreateWorkflow(typeof(RulesAndWorkflows.Workflow1));
wr.StopRuntime();
wr.Dispose();
wr = null;
Here are the early-binding results (in release mode):
Note: running same code again results in no additional memory consumption:
In the second type of test I wanted to profile the memory utilization when loading assemblies “manually”, i.e. using late binding:
AppDomain.CurrentDomain.CreateInstanceAndUnwrap("System.Workflow.Runtime", "System.Workflow.Runtime.WorkflowRuntime");
AppDomain.CurrentDomain.Load("System.Workflow.ComponentModel");
AppDomain.CurrentDomain.Load("System.Workflow.Activities");
Below are the late-binding results (in release mode, without workflow creation):
Now, armed with data, you can draw your own conclusions about the WF footprint. Of course, keep in mind, that the “real-life” applications will have significantly larger baseline memory utilization than my primitive sample did…