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

memory leak - high memory usage #546

Open
helmut72 opened this issue Mar 26, 2024 · 14 comments
Open

memory leak - high memory usage #546

helmut72 opened this issue Mar 26, 2024 · 14 comments
Labels
help wanted Extra attention is needed needs-investigation More detailed look is needed

Comments

@helmut72
Copy link

I run dagu with a single instance for about 9 days. Still testing dagu with 3 cronjobs that runs every few minutes. RAM usage starts at around 15MB. After 9 days it use 92MB RAM. In the past it even use over 300MB RAM with a longer uptime.

@yohamta yohamta added the bug Something isn't working label Mar 26, 2024
@yohamta
Copy link
Collaborator

yohamta commented Mar 26, 2024

Thanks for reporting the issue. Let's try to fix this.

@helmut72
Copy link
Author

Thank you. I have started a second instance with example cronjobs. If RAM usage goes up too after some days, I'll share this example.

@helmut72
Copy link
Author

helmut72 commented Mar 29, 2024

My test instance starts at about 10 MB RAM and now need 60 MB RAM. In 3 days.

Command:

docker run -d --name dagu-test --rm -p 8080:8080 -v ./dags:/home/dagu/.dagu/dags -v ./dagu/data:/home/dagu/.dagu/data -v ./logs:/home/dagu/.dagu/logs yohamta/dagu:latest dagu start-all

Using 4 dags from your example:

./dags/hello1.yaml:

name: hello1 

schedule: "*/9 * * * *"

steps:
  - name: get fake json data
    executor: http
    command: GET https://jsonplaceholder.typicode.com/comments
    script: |
      {
        "timeout": 10,
        "headers": {},
        "query": {
          "postId": "1"
        },
        "body": ""
      }

./dags/hello2.yaml:

name: hello2 

schedule: "*/3 * * * *"

steps:
  - name: get fake json data
    executor: http
    command: GET https://jsonplaceholder.typicode.com/comments
    script: |
      {
        "timeout": 10,
        "headers": {},
        "query": {
          "postId": "1"
        },
        "body": ""
      }

./dags/hello3.yaml:

name: hello3 

schedule: "*/5 * * * *"

steps:
  - name: get fake json data
    executor: http
    command: GET https://jsonplaceholder.typicode.com/comments
    script: |
      {
        "timeout": 10,
        "headers": {},
        "query": {
          "postId": "1"
        },
        "body": ""
      }

./dags/hello4.yaml:

name: hello4 

schedule: "*/7 * * * *"

steps:
  - name: get fake json data
    executor: http
    command: GET https://jsonplaceholder.typicode.com/comments
    script: |
      {
        "timeout": 10,
        "headers": {},
        "query": {
          "postId": "1"
        },
        "body": ""
      }

My other instance now runs for 12 days and need 122 MB RAM.

Btw, running of course your latest v1.12.11 release. Thank you.

@yohamta
Copy link
Collaborator

yohamta commented Mar 29, 2024

Thanks a lot! Will try to pprof using these examples.

@helmut72
Copy link
Author

helmut72 commented May 9, 2024

Can you reproduce the memory leak?

@yohamta
Copy link
Collaborator

yohamta commented May 9, 2024

Sorry, not yet because of my bandwidth, but I have removed some unnecessary heap allocations to fix other problems. So it might solve the problem to some extent.

@yohamta yohamta added needs-investigation More detailed look is needed and removed bug Something isn't working labels May 11, 2024
@helmut72
Copy link
Author

Ok, will try it after a new release.

@yohamta
Copy link
Collaborator

yohamta commented May 21, 2024

Btw, would you mind clarify the context where you're running Dagu? :) I'm wondering what makes the memory usage so important on your environment.

@helmut72
Copy link
Author

Some Raspberry Pi provides only 1GB of RAM or even less (512MB!). It makes you sensible for RAM usage. Any swapping means higher wearing of the SD card and you really don't like a system that is crashed for this reason.

But regardless of this, I think any memory leak is something that should be fixed:
https://en.wikipedia.org/wiki/Memory_leak

@yohamta
Copy link
Collaborator

yohamta commented May 21, 2024

I see, thanks for your clarification.

@helmut72 helmut72 changed the title high memory usage memory leak - high memory usage Jun 2, 2024
@helmut72
Copy link
Author

helmut72 commented Jun 2, 2024

Still the same problem with v1.13.0

@yohamta
Copy link
Collaborator

yohamta commented Jun 3, 2024

Thank you very much for checking it. Let's continue investigation.

@helmut72
Copy link
Author

helmut72 commented Jun 7, 2024

This test instance still runs and use 90MB RAM. It started with 10MB RAM 5 days ago!

To force it, I have changed the timings to */1, */2, */3 and */4 minutes in my example above.

It's not just an HTTP request. I've only used your example because it's simple. Mem usage also goes up with other scripts.

@yohamta
Copy link
Collaborator

yohamta commented Jun 8, 2024

Thanks for the info! I think we can add code to trigger garbage collection after each DAG completes. Additionally, let's implement some APIs and logging to track the running goroutines, memory, and CPU for better debugging and monitoring. We need to investigate the memory usage in more detail, but needs a bit more time. I hope we can get some help for it.

@yohamta yohamta added the help wanted Extra attention is needed label Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed needs-investigation More detailed look is needed
Projects
None yet
Development

No branches or pull requests

2 participants