Memory leak when using Workflow 4.0 SqlWorkflowInstanceStore and PersistableIdleAction.Unload
- by Rohland
Hi,
This particular problem is driving me nuts. I wonder if anyone has experienced a similar problem. If I load up a workflow then unload it and perform a memory snapshot then the result is predictable - my workflow is no longer in memory. However, if I load up a workflow and set the PersistableIdle action to PersistableIdleAction.Unload and let the workflow idle the workflow remains in memory even though the Unload action fires.
I used ANTS Memory Profiler to debug this issue. This is the object retention graph outputted showing that an internal object is hanging onto my workflow instance.
Can anyone else verify this problem? My code amounts to the following:
Create SqlWorkflowInstanceStore and setup lock owner handle
-- At this point I take a memory snapshot
Create an instance of Workflow1
Set the PersistableIdle action
Apply the instancestore to Workflow1
Setup action event handlers for Idle, Unload, UnhandledException etc.
Persist the workflow instance
Run the workflow instance
Wait for instance to idle (caused by Delay activity)
Ensure the Unload action is fired
-- At this point I take a second memory snapshot
From the above image, it is clear that the only object referencing Workflow1 is some internal event handlers result which I have no ability to dispose of.
Any clues?