Slow progressive Memory Leak with Docker Container #12258

Closed
opened 2025-11-02 10:03:40 -06:00 by GiteaMirror · 10 comments
Owner

Originally created by @Merith-TK on GitHub (Dec 24, 2023).

Description

I have noticed over the years I have spent using gitea, it has an slow progressive memory leak,
In the span of 11 hours of relatively zero activity, gitea has nearly doubled its memory usage,
going from ~130mb to now ~240mb usage,

Before I got in contact with people on the discord to address this issue officially, gitea was consuming nearly 6gb of ram, which if I wanted an git service to consume that much, I would self host gitlab lol

Gitea Version

1.21.3+8-gf2add36a2

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

https://gist.github.com/Merith-TK/657357fc8e60e0928aa3e1f155799472

Screenshots

No response

Git Version

Nightly Docker Container

Operating System

Linux Host, Nightly Docker Container

How are you running Gitea?

Docker compose.

  gitea:
    container_name: gitea
    image: gitea/gitea:1.21-nightly
    restart: unless-stopped
    environment:
      USER_UID: 1001
      USER_GID: 1001
    networks:
      # unified networking for cross container connections
      - caddy
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    labels:
      # caddyserver configs
      caddy: git.merith.xyz
      caddy.reverse_proxy: "{{upstreams 3000}}"

Database

PostgreSQL

Originally created by @Merith-TK on GitHub (Dec 24, 2023). ### Description I have noticed over the years I have spent using gitea, it has an *slow* progressive memory leak, In the span of 11 hours of relatively zero activity, gitea has nearly doubled its memory usage, going from ~130mb to now ~240mb usage, Before I got in contact with people on the discord to address this issue officially, gitea was consuming nearly 6gb of ram, which if I wanted an git service to consume that much, I would self host gitlab lol ### Gitea Version 1.21.3+8-gf2add36a2 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist https://gist.github.com/Merith-TK/657357fc8e60e0928aa3e1f155799472 ### Screenshots _No response_ ### Git Version Nightly Docker Container ### Operating System Linux Host, Nightly Docker Container ### How are you running Gitea? Docker compose. ```yml gitea: container_name: gitea image: gitea/gitea:1.21-nightly restart: unless-stopped environment: USER_UID: 1001 USER_GID: 1001 networks: # unified networking for cross container connections - caddy volumes: - ./gitea:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro labels: # caddyserver configs caddy: git.merith.xyz caddy.reverse_proxy: "{{upstreams 3000}}" ``` ### Database PostgreSQL
GiteaMirror added the issue/needs-feedback label 2025-11-02 10:03:40 -06:00
Author
Owner

@Merith-TK commented on GitHub (Dec 24, 2023):

And I wasnt given an space to do so since its an "new feature" in the nightly,
gitea-diagnosis-20231224-082221.zip
STACKTRACE

@Merith-TK commented on GitHub (Dec 24, 2023): And I wasnt given an space to do so since its an "new feature" in the nightly, [gitea-diagnosis-20231224-082221.zip](https://github.com/go-gitea/gitea/files/13762382/gitea-diagnosis-20231224-082221.zip) STACKTRACE
Author
Owner

@wxiaoguang commented on GitHub (Dec 24, 2023):

It seems that there is no memory leaking from Gitea itself.

image

The memory usage seems alright.

Could you figure out what process is the holding the largely leaked memory?

@wxiaoguang commented on GitHub (Dec 24, 2023): It seems that there is no memory leaking from Gitea itself. ![image](https://github.com/go-gitea/gitea/assets/2114189/dfdce4de-b12f-4374-8383-f235d7bc60f2) The memory usage seems alright. Could you figure out what process is the holding the largely leaked memory?
Author
Owner

@Merith-TK commented on GitHub (Dec 25, 2023):

image
so... this is confusing. I ran top in the container and its memory usage according to top looks right, but with docker stats gitea its not

@Merith-TK commented on GitHub (Dec 25, 2023): ![image](https://github.com/go-gitea/gitea/assets/10422110/b2f69f41-7e41-4456-bf39-6cad5b8cd650) so... this is confusing. I ran top in the container and its memory usage according to top looks right, but with `docker stats gitea` its not
Author
Owner

@wxiaoguang commented on GitHub (Dec 25, 2023):

That's a big topic. VSZ is not what you need.

Maybe you could read this for more information: https://stackoverflow.com/questions/131303/how-can-i-measure-the-actual-memory-usage-of-an-application-or-process

And I think this issue could be closed at the moment.

@wxiaoguang commented on GitHub (Dec 25, 2023): That's a big topic. VSZ is not what you need. Maybe you could read this for more information: https://stackoverflow.com/questions/131303/how-can-i-measure-the-actual-memory-usage-of-an-application-or-process And I think this issue could be closed at the moment.
Author
Owner

@Merith-TK commented on GitHub (Dec 25, 2023):

Nah, don't close as I have noticed this issue on multiple different machines. Will rename to be docker specific however as I have only ever used the docker image

@Merith-TK commented on GitHub (Dec 25, 2023): Nah, don't close as I have noticed this issue on multiple different machines. Will rename to be docker specific however as I have only ever used the docker image
Author
Owner

@wxiaoguang commented on GitHub (Dec 25, 2023):

I do not think it's related to docker either, nor worth to keep it open.

IIRC that's the default OS memory management behavior IMO?

If it really affects your system (eg: OOM), or you could figure out "how to fix", feel free to reopen then.

Or, if it is a docker bug, it should be reported to docker team.

@wxiaoguang commented on GitHub (Dec 25, 2023): I do not think it's related to docker either, nor worth to keep it open. IIRC that's the default OS memory management behavior IMO? If it really affects your system (eg: OOM), or you could figure out "how to fix", feel free to reopen then. Or, if it is a docker bug, it should be reported to docker team.
Author
Owner

@Merith-TK commented on GitHub (Dec 25, 2023):

Bug has existed with the docker container for several years and major versions, I have not tested this with direct binary running,

I.. wtf
image
I just checked it and its at this point its using 5gb of memory

but htop (running as root on host) reports that the gitea binary is only reporting 250mb
and running htop in the container (docker compose exec gitea bash -c "apk update && apk add htop && htop" doesnt show anything unnessecary?
image
gitea-diagnosis-20231225-015948.zip

as well as an updated diagnosis file.

Please do note that this is the only container I have ever had have this problem, across multiple machines and multiple configurations and major versions of gitea. this is consistant and does actually consume that much memory

@Merith-TK commented on GitHub (Dec 25, 2023): Bug has existed with the docker container for several years and major versions, I have not tested this with direct binary running, I.. wtf ![image](https://github.com/go-gitea/gitea/assets/10422110/d1183b8c-3bb6-44f6-a6fb-0100abc10594) I just checked it and its at this point its using 5gb of memory but htop (running as root on host) reports that the gitea binary is only reporting 250mb and running htop in the container (`docker compose exec gitea bash -c "apk update && apk add htop && htop"` doesnt show anything unnessecary? ![image](https://github.com/go-gitea/gitea/assets/10422110/5b862058-352e-4f98-8ddb-aedad3578785) [gitea-diagnosis-20231225-015948.zip](https://github.com/go-gitea/gitea/files/13765514/gitea-diagnosis-20231225-015948.zip) as well as an updated diagnosis file. Please do note that *this is the only container* I have ever had have this problem, across *multiple* machines and *multiple* configurations and major versions of gitea. this is consistant and does actually consume that much memory
Author
Owner

@lunny commented on GitHub (Dec 25, 2023):

What's your docker version? Have you upgraded it to the latest stable version?

@lunny commented on GitHub (Dec 25, 2023): What's your docker version? Have you upgraded it to the latest stable version?
Author
Owner

@wxiaoguang commented on GitHub (Dec 25, 2023):

The memory problem is a big topic. What you see might not be what it really is.

Maybe you need more time and approaches to understand what really happens.

For example:

These are just some samples, still not the full story. As we discussed many times above: it is a big topic, and it doesn't seem to be related to Gitea. And maybe it is even not a real problem -- if your system works well and there is no OOM.

@wxiaoguang commented on GitHub (Dec 25, 2023): The memory problem is a big topic. What you see might not be what it really is. Maybe you need more time and approaches to understand what really happens. For example: * https://github.com/moby/moby/issues/40415 * https://unix.stackexchange.com/questions/451252/cgroup-memory-usage-in-bytes-shows-incorrect-value * https://medium.com/@bobzsj87/demist-the-memory-ghost-d6b7cf45dd2a These are just some samples, still not the full story. As we discussed many times above: it is a big topic, and it doesn't seem to be related to Gitea. And maybe it is even not a real problem -- if your system works well and there is no OOM.
Author
Owner

@Merith-TK commented on GitHub (Dec 26, 2023):

What's your docker version? Have you upgraded it to the latest stable version?

please note that I have stated this has been noticeably happening for years. across multiple sets of hardware. so docker version is not really an factor here
Ubuntu, Arch, WSL, all on their latest kernels (currently Arch with kernel 6.6.2)

But yah... I just restarted the container and system memory (according to htop) dropped from 17.6, to 17.5, and then back yo 17.6 as the container came back on... So// genuinely have zero clue what the fuck is going on now

@Merith-TK commented on GitHub (Dec 26, 2023): > What's your docker version? Have you upgraded it to the latest stable version? please note that I have stated this has been noticeably happening for *years*. across *multiple* sets of hardware. so docker version is not really an factor here Ubuntu, Arch, WSL, all on their latest kernels (currently Arch with kernel 6.6.2) But yah... I just restarted the container and system memory (according to htop) dropped from 17.6, to 17.5, and then back yo 17.6 as the container came back on... So// genuinely have zero clue what the fuck is going on now
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12258