Xray-core: Memory leak
There is / has been a memory leak issue since at least version 1.8.9. I have tested the latest release, and it is leaking at a rate of about 1.7 GB for every 100 GB of traffic proxied, during a time frame of 24 hours and with 50 active users. I have not done experiments to correlate these numbers with each other, but it seems like the amount of leaked memory is proportional to the served traffic. There is also no ceiling to this, it just grows until systemd-oomd kills it. I have tried using vless only, vless+vmess and vless+trojan, and avoided the newly added transports but to no avail. I would be more than happy to experiment more and provide the team with more information. I am running xray behind haproxy and that behind cloudflare CDN.
OS: Ubuntu 22.04, all packages up-to-date.
Architecture: Armv8, Neoverse-N1 at Hetzner. Also generic x86 platforms.
Memory: 4GB
Kernel: Generic Ubuntu 5.15.0-xxx
Logging: Disabled
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 24 (3 by maintainers)
Commits related to this issue
- refactor: change to v2raya source with xray-core < 1.8.8 (https://github.com/XTLS/Xray-core/issues/3221) — committed to alryaz/openwrt-ax3600-builds by alryaz 2 years ago
- Revert "refactor: change to v2raya source with xray-core < 1.8.8 (https://github.com/XTLS/Xray-core/issues/3221)" This reverts commit ada9528caac565aa3a12f5905a444244113c7031. — committed to alryaz/openwrt-ax3600-builds by alryaz 2 years ago
- Core: Fix memory leaks with RequireFeatures() (#4095) Fixes https://github.com/XTLS/Xray-core/issues/4054 Fixes https://github.com/XTLS/Xray-core/issues/3338 Fixes https://github.com/XTLS/Xray-core/i... — committed to XTLS/Xray-core by yuhan6665 2 years ago
- Core: Fix memory leaks with RequireFeatures() (#4095) Fixes https://github.com/XTLS/Xray-core/issues/4054 Fixes https://github.com/XTLS/Xray-core/issues/3338 Fixes https://github.com/XTLS/Xray-core/i... — committed to zxspirit/Xray-core by yuhan6665 2 years ago
I think this issue has become about too many things at once (socket/filedescriptor leak versus memory leak) and each of the reports is not very specific. I suggest to attempt these things:
@mmmray, i testing this patch, that can be used as hack way to fix memory leak. I using simple XTLS-Reality setup and without fix 8-10 clients gives xray memory usage up to 700-800 mb in one day (OOM kills service). With fix, memory peak usage reaches 150mb. At least, it gives info about mem leak place, i hope, it will help to fix.
same problem , in my experience , version 1.8.4 is fine , and after that version , xray will leak
I’m using version 1.8.16 and problem solved. except shadowsocks2022, still leak
Same issue on MT7981A (ARM64, cortex A53) with 512MB RAM, have try 1.8.4 and 1.8.10, both consume all RAM on device after first speedtest running and hangs, switch to sing-box 1.8.10 without change anything on server side (xray-core 1.8.10) and have no issues with memory consumption (~180 MB RAM after 10 and more tests).
P.S. buffer-size is set to 4