#I have seen memory leak in sentry-web. How do we control its memory usage
4 messages · Page 1 of 1 (latest)
Hi @flat rune. I'm happy to dig into this for you! I'll check my internal sources for answers to your question! :wave:
If you're experiencing memory leaks or high memory usage in the Sentry web service (sentry-web), especially in self-hosted environments, there are a few steps and workarounds reported by the community that may help control memory usage:
-
Set ulimits for the web container
Addingulimitsto your Docker Compose configuration for thewebservice has been shown to help control memory usage and prevent runaway resource consumption. For example, you can add the following to yourdocker-compose.ymlunder thewebservice:web: ... ulimits: nofile: soft: 4096 hard: 4096Users have reported that this change stabilized memory usage and resolved the issue of the web container consuming excessive RAM over time. This fix has been merged into the official self-hosted repository as well.
See details and confirmation from users and resolution in the self-hosted repo. -
Monitor for underlying issues
In some cases, high memory usage was linked to the underlying OS or Docker environment (e.g., RHEL/Rocky Linux vs. Debian). If you continue to see issues after applying theulimitsfix, consider testing on a different OS or Docker version to rule out environment-specific problems
Discussion of OS-related issues. -
Profile memory usage
If the problem persists, Sentry maintainers have recommended attaching a memory profiler (such asmemray) to the web process to identify the source of the leak. This can help pinpoint whether the issue is with Sentry itself or with the environment
Profiling suggestion.
- Upgrade to the latest version
Ensure you are running the latest version of Sentry self-hosted, as memory management improvements and bug fixes are released regularly.
Summary:
The most effective and confirmed solution is to set ulimits for the web container in your Docker Compose configuration. If memory usage still grows uncontrollably, consider profiling the process and reviewing your OS/Docker environment for compatibility issues.