elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.27k stars 1.15k forks source link

[BUG] C# scripting memory leak #5390

Open ichibisov opened 4 months ago

ichibisov commented 4 months ago

Description

Using c# script in Condition causes memory leak.

Steps to Reproduce

Create a workflow with While loop with condition 'true' in c#, in the body of the loop just add Delay activity. The workflow attached. Check resource consumption for the container.

  1. Attachments: c-sharp-memory-leak.json

  2. Reproduction Rate: Indicate how often the bug occurs when following these steps (e.g., "every time", "intermittently: about 50% of the time").

Expected Behavior

No memory leaks

glime-ai[bot] commented 4 months ago

To address the issue of a memory leak when using a C# script in a condition within an Elsa workflow, it is important to first ensure that you are using the latest version of Elsa, as memory leak issues may have been addressed in more recent updates. If you are already on the latest version and the problem persists, it would be advisable to report this issue on the Elsa GitHub repository's issue tracker, providing all the relevant details including the steps to reproduce, the workflow definition (as a JSON file), and the observed behavior.

In the meantime, as a workaround, you could try to refactor the workflow to avoid using C# scripts if possible, or to minimize the use of such scripts. Additionally, you could monitor the memory usage and implement a mechanism to restart the workflow host if a certain threshold is reached to prevent the application from crashing.

If you need further assistance with this issue, please provide more details such as the version of Elsa you are using, the specific workflow that is causing the memory leak, and any other relevant configuration details.

This comment was generated by Glime.