gogs icon indicating copy to clipboard operation
gogs copied to clipboard

Huge and always increasing memory

Open Ailsa-Wu opened this issue 4 years ago • 3 comments

Describe the bug

The memory of our gogs will keeping increasing. And then it will be killed because of OOM after few days. We use it to store gitops repos and a little helm charts , so we will pull and push frequently. Our largest repo is about 22M and others are all about dozens of KB. Total size is smaller than 100M. I'm just guess that there is memory leak. We use it in production env., so it is really confused us. Any response or suggestion will be appreciated. Thx.

As the monitor graph shows, the memory increase day by day. image

That's the statistic data on Gogs. image

Gogs version and commit

v0.11.86.0130

Git version

$ git version

We use golang to push and pull git repo. github.com/go-git/go-git/v5 v5.2.0

Operating system

GKE Version: 1.18.12-gke.1210

Database

PostgreSQL 13 on GCP GCP Cloud Filestore for local storage. image

To Reproduce Steps to reproduce the behavior:

Start Gogs and run about a fews days.

Can you reproduce the bug at https://try.gogs.io?

Expected behavior

Memory stabilizes on a reasonable value

Actual behavior

Always increase

Screenshots

Additional context

Ailsa-Wu avatar Mar 31 '21 09:03 Ailsa-Wu

I encountered the same problem. The server often freezes unexpectedly, and after a while, the gogs process is killed by the system

Image

aikeep avatar Aug 06 '25 17:08 aikeep

I have probably found the reason. My service is deployed on the public network, and by checking nginx access_log and error_log, there are a large number of requests, mostly from web spider. By checking the Gogs control panel, the GC frequency is between 0.1s-5s, and the system CPU usage is very high. Then I configured robots.txt on nginx, but it didn't work because many spider don't follow the robots protocol at all. So I used uwf ban to block some IP segments, and the GC frequency is basically above 100 seconds. I think this is the reason for the memory explosion.

aikeep avatar Aug 07 '25 09:08 aikeep

I have the same issue with Gitea and because IP filtering was not a scalable solution in my view, I put Anubis in front of Gitea (and other things). I guess the same can work for Gogs.

SansGuidon avatar Oct 27 '25 04:10 SansGuidon