Workflow Designer 4.0 Performance Issue: possible memory leak - by Nestoyanov Vladimir

Status : 

  Accepted<br /><br />
		The product team has accepted this issue and will be determining when the issue will be addressed.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 777780 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/29/2013 9:19:14 AM
Access Restriction Public


I am trying to implement a workflow designer in a windows form application and use the same designer to view different workflows. However, I found the program became slower and slower after loading several workflows.

my steps are as follows:

1. Create a WPF user control to package the workflowdesigner.

2. In the user control, create a new workflowDesigner instance each time when called. I suppose the old workflowDesigner instance would be collected by GC.

3. Create a Winform control and install the WPF user control created on step 2 into an element host, and put the element host on the winform userControl. 

4. Load Winform user control created in stpe 3 into a Tab inside a Winform application.

5. Using a button to launch and close the tab. 

The result: First time when I launch the tab it consumes around 30MB of space (may be due to first time WPF assembly load), from next time onwards it takes 13MB in each launch and after 30-40 launch attempts memory consumption become large enough to me make application too slow.

I am disposing following objects explicitly:
Element host.

   private void InitializeWorkflowDesigner()
            workflowDesigner = new WorkflowDesigner();
            workflowDesigner.Context.Items.GetValue<ReadOnlyState>().IsReadOnly = true;
            workflowDesigner.View.PreviewMouseDown += OnPreviewMouseDown;
            attachPropertyRecord = new AttachedProperty<ActivityStateRecord>
                Name = "Record",
                Setter = (modelItem, tracingRecord) => modelItemMapping.SetRecordValue(modelItem, tracingRecord), // modelItemMapping is a class which provide mappings.
                Getter = modelItem => modelItemMapping.GetRecordValue(modelItem),
                OwnerType = typeof(Activity)
            grid.Children.Add(workflowDesigner.View); // grid is Grid of WPF control.

            var modelService = workflowDesigner.Context.Services.GetService<ModelService>();
            sourceLocationProvider = new SourceLocationProvider(
            var designerView = workflowDesigner.Context.Services.GetService<DesignerView>();
            if (designerView != null)
                designerView.WorkflowShellBarItemVisibility = // ShellBarItemVisibility.Imports |
                    ShellBarItemVisibility.MiniMap | // ShellBarItemVisibility.Variables |
                    // ShellBarItemVisibility.Arguments | <-- Uncomment to show again

/// Method which we call inside "SourceLocationProvider" constructor.
        private void UpdateSourceLocationMappingInDebuggerService(string workflowFilePath, DebuggerService debuggerService, string loadedFile, object rootInstance)
            workflowElementToSourceLocationMap = new Dictionary<object, SourceLocation>();
            designerSourceLocationMapping = new Dictionary<object, SourceLocation>();

            if (rootInstance != null)
                Activity documentRootElement = GetRootWorkflowElement(rootInstance);


                // Collect the mapping between the Model Item tree and its underlying source location

            // Notify the DebuggerService of the new sourceLocationMapping.
            // When rootInstance == null, it'll just reset the mapping.
            // DebuggerService debuggerService = debuggerService as DebuggerService;
            if (debuggerService != null)
Sign in to post a comment.
Posted by Microsoft on 3/27/2013 at 2:29 PM
Following the steps that you have mentioned here, we couldn't find any WF Designer leaks.

Please provide a repro project and more detailed repro steps if the problem persists.
Posted by Microsoft on 2/19/2013 at 11:31 AM
Thank you for your feedback.

We are looking into this issue. But for our investigation, we would need more details than what has already been mentioned in the bug.

Could you please attach a repro project to the bug?

We appreciate your help.
Posted by Microsoft on 1/29/2013 at 6:04 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 1/29/2013 at 9:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(