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

[BUG]Memory Leak: RunTask activities remain in memory after workflow completion #6266

Open
coolshun opened this issue Jan 3, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@coolshun
Copy link

coolshun commented Jan 3, 2025

Title: Memory Leak: RunTask activities remain in memory after workflow completion

Issue Description

Using Visual Studio's Diagnostic Tools, we observed that RunTask activity instances are not being garbage collected after workflow completion. These instances, along with their associated contexts and cancellation tokens, remain in memory.

Diagnostic Evidence

Visual Studio Diagnostic Tools shows retained objects:
微信图片_20250103081215

Steps to Reproduce

  1. Create a workflow with RunTask activities,the workflow design json is
    并发测试.json

  2. Execute the workflow

  3. Open Visual Studio Diagnostic Tools (Memory Usage)

  4. Force GC and observe retained objects

  5. Note that RunTask instances and associated objects remain in memory

Impact

Memory usage grows over time as workflows are executed, particularly noticeable in long-running applications with frequent workflow executions.

Environment

  • Elsa Version: 3.2.3
  • .NET Version: 8.0
  • Visual Studio 2022
@coolshun coolshun added the bug Something isn't working label Jan 3, 2025
@sfmskywalker sfmskywalker self-assigned this Jan 10, 2025
@sfmskywalker sfmskywalker moved this to Triage in ELSA 3 Jan 10, 2025
@sfmskywalker
Copy link
Member

I don't think this is a memory leak because it is normal for the workflow definition and its activities to remain in memory, because workflow definitions are cached using a memory cache.

When I run your sample workflow, no matter how many times, I don't see memory consumption increasing for each run.

@sfmskywalker
Copy link
Member

On second review, the WorkflowExecutionContexts should not remain in memory. I will try and see if I can reproduce this with the latest version from the main branch.

@sfmskywalker
Copy link
Member

After an initial look, I don't see any evidence of an increasing count of WorkflowExecutionContexts. However, the GC doesn't immediately remove objects, so I do see it might take a brief while before they get collected (matter of seconds).

In summary, I don't see any memory leaks in the latest source code of the main branch. Perhaps you can try and test against the latest preview version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Triage
Development

No branches or pull requests

2 participants