Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High memory usage running workflow xaml #279

Open
chenjackms opened this issue Aug 10, 2023 · 0 comments
Open

High memory usage running workflow xaml #279

chenjackms opened this issue Aug 10, 2023 · 0 comments

Comments

@chenjackms
Copy link

chenjackms commented Aug 10, 2023

Hi, I am attempting to migrate existing workflow code to .net6 and leveraging CoreWF. When running existing xaml workflow I'm encountering high memory usage compared to previously under .netframework. ie. 500+ mb vs under 100mb. For larger xamls the memory usage will spike to 1.6GB and result in outofmemoryexceptions:

Exception, System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
   at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb)
   at System.Reflection.Internal.StreamMemoryBlockProvider.ReadMemoryBlockNoLock(Stream stream, Boolean isFileStream, Int64 start, Int32 size)
   at System.Reflection.PortableExecutable.PEReader..ctor(Stream peStream, PEStreamOptions options, Int32 size)
   at Microsoft.CodeAnalysis.ModuleMetadata.CreateFromStream(Stream peStream, PEStreamOptions options)
   at Microsoft.CodeAnalysis.Scripting.Hosting.RuntimeMetadataReferenceResolver.<>c.<.ctor>b__11_0(String path, MetadataReferenceProperties properties)
   at Microsoft.CodeAnalysis.Scripting.Hosting.RuntimeMetadataReferenceResolver.ResolveMissingAssembly(MetadataReference definition, AssemblyIdentity referenceIdentity)
   at Microsoft.CodeAnalysis.Scripting.ScriptMetadataResolver.ResolveMissingAssembly(MetadataReference definition, AssemblyIdentity referenceIdentity)
   at Microsoft.CodeAnalysis.CommonReferenceManager`2.ResolveAndBindMissingAssemblies(TCompilation compilation, ImmutableArray`1 explicitAssemblies, ImmutableArray`1 explicitModules, ImmutableArray`1 explicitReferences, ImmutableArray`1 explicitReferenceMap, MetadataReferenceResolver resolver, MetadataImportOptions importOptions, Boolean supersedeLowerVersions, ArrayBuilder`1 referenceBindings, Dictionary`2 assemblyReferencesBySimpleName, ImmutableArray`1& allAssemblies, ImmutableArray`1& metadataReferences, ImmutableArray`1& resolvedReferences, ImmutableDictionary`2& implicitReferenceResolutions, DiagnosticBag resolutionDiagnostics)
   at Microsoft.CodeAnalysis.CommonReferenceManager`2.Bind(TCompilation compilation, ImmutableArray`1 explicitAssemblies, ImmutableArray`1 explicitModules, ImmutableArray`1 explicitReferences, ImmutableArray`1 explicitReferenceMap, MetadataReferenceResolver resolverOpt, MetadataImportOptions importOptions, Boolean supersedeLowerVersions, Dictionary`2 assemblyReferencesBySimpleName, ImmutableArray`1& allAssemblies, ImmutableArray`1& implicitlyResolvedReferences, ImmutableArray`1& implicitlyResolvedReferenceMap, ImmutableDictionary`2& implicitReferenceResolutions, DiagnosticBag resolutionDiagnostics, Boolean& hasCircularReference, Int32& corLibraryIndex)
   at Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.ReferenceManager.CreateAndSetSourceAssemblyFullBind(VisualBasicCompilation compilation)
   at Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.ReferenceManager.CreateSourceAssemblyForCompilation(VisualBasicCompilation compilation)
   at Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.get_SourceModule()
   at Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.get_CommonSourceModule()
   at Microsoft.CodeAnalysis.Compilation.CommonBindScriptClass()
   at Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.BindScriptClass()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.get_CommonScriptClass()
   at System.Activities.ScriptingJitCompiler.CompileExpression(ExpressionToCompile expressionToCompile)
   at System.Activities.JitCompilerHelper`1.Compile[T](LocationReferenceEnvironment environment, Boolean isLocationReference)
   at System.Activities.JitCompilerHelper`1.Compile[T](CodeActivityPublicEnvironmentAccessor publicAccessor, Boolean isLocationReference)
   at Microsoft.VisualBasic.Activities.VisualBasicHelper.Compile[T](String expressionText, CodeActivityPublicEnvironmentAccessor publicAccessor, Boolean isLocationExpression)
   at Microsoft.VisualBasic.Activities.VisualBasicValue`1.CacheMetadata(CodeActivityMetadata metadata)
   at System.Activities.CodeActivity`1.OnInternalCacheMetadataExceptResult(Boolean createEmptyBindings)
   at System.Activities.Activity`1.OnInternalCacheMetadata(Boolean createEmptyBindings)
   at System.Activities.Activity.InternalCacheMetadata(Boolean createEmptyBindings, IList`1& validationErrors)
   at System.Activities.ActivityUtilities.ProcessActivity(ChildActivity childActivity, ChildActivity& nextActivity, Stack`1& activitiesRemaining, ActivityCallStack parentChain, IList`1& validationErrors, ProcessActivityTreeOptions options, ProcessActivityCallback callback)
   at System.Activities.ActivityUtilities.ProcessActivityTreeCore(ChildActivity currentActivity, ActivityCallStack parentChain, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList`1& validationErrors)
   at System.Activities.ActivityUtilities.CacheRootMetadata(Activity activity, LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList`1& validationErrors)
   at System.Activities.Hosting.WorkflowInstance.ValidateWorkflow(WorkflowInstanceExtensionManager extensionManager)
   at System.Activities.Hosting.WorkflowInstance.RegisterExtensionManager(WorkflowInstanceExtensionManager extensionManager)
   at System.Activities.WorkflowApplication.EnsureInitialized()
   at System.Activities.WorkflowApplication.Enqueue(InstanceOperation operation, Boolean push)
   at System.Activities.WorkflowApplication.Enqueue(InstanceOperation operation)
   at System.Activities.WorkflowApplication.WaitForTurn(InstanceOperation operation, TimeSpan timeout)
   at System.Activities.WorkflowApplication.InternalRun(TimeSpan timeout, Boolean isUserRun)
   at System.Activities.WorkflowApplication.Run(TimeSpan timeout)
   at System.Activities.WorkflowApplication.Run()

It appears this is CoreWF is trying to cache assemblies when loading the workflow. Wondering if this is expected behavior and if there are workarounds/fixes other than shortening the existing xaml? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant