[GH-ISSUE #1299] Memory leaks when using the VPN for prolonged periods of time (Linux) #509

Open
opened 2026-10-13 20:23:03 +00:00 by bsakaguchi · 6 comments
Owner

Originally created by @kxddry on GitHub (Dec 11, 2024).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/1299

Describe the bug
Being connected to a private server via XRay, memory leaks are present after several hours of usage or suspending and waking the laptop up while connected to the VPN.

To Reproduce
Steps to reproduce the behavior:

  1. Open up AmneziaVPN
  2. Connect to a server
  3. Wait several hours, perhaps suspend the laptop without disconnecting
  4. Memory leaks appear--AmneziaVPN takes up ~4GiB of RAM.
  • OS: Arch Linux
  • Linux 6.12.3-arch1-1
  • Wayland (Hyprland)
  • 16GB of RAM
  • Ryzen 7 7840HS

Server:

  • OS: Debian GNU/Linux 12 (bookworm) x86_64 linux 6.1.0-26-amd64
Originally created by @kxddry on GitHub (Dec 11, 2024). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/1299 **Describe the bug** Being connected to a private server via XRay, memory leaks are present after several hours of usage or suspending and waking the laptop up while connected to the VPN. **To Reproduce** Steps to reproduce the behavior: 1. Open up AmneziaVPN 2. Connect to a server 3. Wait several hours, perhaps suspend the laptop without disconnecting 4. Memory leaks appear--AmneziaVPN takes up ~4GiB of RAM. - OS: Arch Linux - Linux 6.12.3-arch1-1 - Wayland (Hyprland) - 16GB of RAM - Ryzen 7 7840HS Server: - OS: Debian GNU/Linux 12 (bookworm) x86_64 linux 6.1.0-26-amd64
Author
Owner

@AKotov-dev commented on GitHub (Dec 12, 2024):

@kxddry
If it is not too much trouble, please provide the command output

ps aux --sort=-%mem | head -n 10

and (if possible)

htop

...or at least a screenshot of the output of the utility that would show that AmneziaVPN is the culprit.

This will help developers and others verify that the problem exists. Thank you.

p.s. is logging enabled in AmneziaVPN? If enabled, try disabling logging... Perhaps logging continues in suspending/waking and this causes memory overflow?

<!-- gh-comment-id:2538162830 --> @AKotov-dev commented on GitHub (Dec 12, 2024): @kxddry If it is not too much trouble, please provide the command output ``` ps aux --sort=-%mem | head -n 10 ``` and (if possible) ``` htop ``` ...or at least a screenshot of the output of the utility that would show that AmneziaVPN is the culprit. This will help developers and others verify that the problem exists. Thank you. p.s. is logging enabled in AmneziaVPN? If enabled, try disabling logging... Perhaps logging continues in suspending/waking and this causes memory overflow?
Author
Owner

@mormih commented on GitHub (Dec 15, 2024):

I have the same issue in my amnezia container after 2d20h uptime.

[Sun Dec 15 18:50:38 2024] Tasks state (memory values in pages):
[Sun Dec 15 18:50:38 2024] [ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj name
[Sun Dec 15 18:50:38 2024] [1937494] 0 1937494 403 14 45056 0 924 init
[Sun Dec 15 18:50:38 2024] [1937657] 0 1937657 340215 37951 438272 0 924 amneziawg-go
[Sun Dec 15 18:50:38 2024] oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=docker-0e9bfb6918a0f0ed48562ca8c21b895790ffe2985bb00d724
136aeeaa80b82bd.scope,mems_allowed=0,oom_memcg=/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod2473cb81_2022_4d4d_b1a9_732bfbc30
fef.slice/docker-0e9bfb6918a0f0ed48562ca8c21b895790ffe2985bb00d724136aeeaa80b82bd.scope,task_memcg=/kubepods.slice/kubepods-burstable.slice/kub
epods-burstable-pod2473cb81_2022_4d4d_b1a9_732bfbc30fef.slice/docker-0e9bfb6918a0f0ed48562ca8c21b895790ffe2985bb00d724136aeeaa80b82bd.scope,tas
k=amneziawg-go,pid=1937657,uid=0
[Sun Dec 15 18:50:38 2024] Memory cgroup out of memory: Killed process 1937657 (amneziawg-go) total-vm:1360860kB, anon-rss:150288kB, file-rss:1
516kB, shmem-rss:0kB, UID:0 pgtables:428kB oom_score_adj:924

<!-- gh-comment-id:2543944715 --> @mormih commented on GitHub (Dec 15, 2024): I have the same issue in my amnezia container after 2d20h uptime. > > [Sun Dec 15 18:50:38 2024] Tasks state (memory values in pages): > [Sun Dec 15 18:50:38 2024] [ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj name > [Sun Dec 15 18:50:38 2024] [1937494] 0 1937494 403 14 45056 0 924 init > [Sun Dec 15 18:50:38 2024] [1937657] 0 1937657 340215 37951 438272 0 924 amneziawg-go > [Sun Dec 15 18:50:38 2024] oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=docker-0e9bfb6918a0f0ed48562ca8c21b895790ffe2985bb00d724 > 136aeeaa80b82bd.scope,mems_allowed=0,oom_memcg=/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod2473cb81_2022_4d4d_b1a9_732bfbc30 > fef.slice/docker-0e9bfb6918a0f0ed48562ca8c21b895790ffe2985bb00d724136aeeaa80b82bd.scope,task_memcg=/kubepods.slice/kubepods-burstable.slice/kub > epods-burstable-pod2473cb81_2022_4d4d_b1a9_732bfbc30fef.slice/docker-0e9bfb6918a0f0ed48562ca8c21b895790ffe2985bb00d724136aeeaa80b82bd.scope,tas > k=amneziawg-go,pid=1937657,uid=0 > [Sun Dec 15 18:50:38 2024] Memory cgroup out of memory: Killed process 1937657 (amneziawg-go) total-vm:1360860kB, anon-rss:150288kB, file-rss:1 > 516kB, shmem-rss:0kB, UID:0 pgtables:428kB oom_score_adj:924 >
Author
Owner

@kxddry commented on GitHub (Dec 20, 2024):

@kxddry If it is not too much trouble, please provide the command output

ps aux --sort=-%mem | head -n 10

Sure thing, here's a screenshot showing the output of ps aux, as well as a screenshot of btop:
amneziaissue1
amneziaissue2

<!-- gh-comment-id:2557236408 --> @kxddry commented on GitHub (Dec 20, 2024): > @kxddry If it is not too much trouble, please provide the command output > > ``` > ps aux --sort=-%mem | head -n 10 > ``` Sure thing, here's a screenshot showing the output of `ps aux`, as well as a screenshot of `btop`: ![amneziaissue1](https://github.com/user-attachments/assets/4f41d638-5b91-4dd2-aa23-6ce78fdcc1d6) ![amneziaissue2](https://github.com/user-attachments/assets/ee35bec7-0d54-4abd-9aa8-1649fe3ca9f2)
Author
Owner

@kxddry commented on GitHub (Dec 20, 2024):

Accidentally closed the issue.

<!-- gh-comment-id:2557236988 --> @kxddry commented on GitHub (Dec 20, 2024): Accidentally closed the issue.
Author
Owner

@AKotov-dev commented on GitHub (Dec 28, 2024):

I assume that the problem is in outdated versions of xray and tun2socks.
The container on the server contains xray-v1.8.6.
1-xray-1 8 6

In turn, on the client:

cd /opt/AmneziaVPN/client/bin
./xray --version
Xray 1.8.7 (Xray, Penetrates Everything.) d20a835 (go1.21.6 linux/amd64)
A unified platform for anti-censorship.

tun2socks does not report its version on the client at all. This is typical of the earliest releases. Meanwhile, the current version is tun2socks-v2.5.2.

Conclusion from the assumption: For normal coordination of the client and server, they must have the same and UPDATED versions of xray installed. Let me remind you that the latest version of xray that supports xray-v1.8 format configurations is Xray-core v24.11.30. The following versions suggest breaking server and client configurations with the transition to XHTTP.

Conclusion: I would try to update xray to version Xray-core v24.11.30, tun2socks-v2.5.2 synchronously: both on the client and on the server.

p.s. I have my own VPS with xray-v24.11.30 (RAM-512MB, 3 clients, REALITY, not Amnezia, not a container) and there are no problems with memory overuse: uptime is more than 1 year. We are waiting for the developers' decision.

<!-- gh-comment-id:2564266523 --> @AKotov-dev commented on GitHub (Dec 28, 2024): I **assume** that the problem is in outdated versions of xray and tun2socks. The container on the **server** contains xray-v1.8.6. ![1-xray-1 8 6](https://github.com/user-attachments/assets/739cc4db-ca8f-4455-a81d-02ae500e5ef0) In turn, on the **client**: ``` cd /opt/AmneziaVPN/client/bin ./xray --version Xray 1.8.7 (Xray, Penetrates Everything.) d20a835 (go1.21.6 linux/amd64) A unified platform for anti-censorship. ``` tun2socks does not report its version on the client at all. This is typical of the earliest releases. Meanwhile, the current version is [tun2socks-v2.5.2](https://github.com/xjasonlyu/tun2socks/releases/tag/v2.5.2). **Conclusion from the assumption:** For normal coordination of the client and server, they must have the same and UPDATED versions of xray installed. Let me remind you that the latest version of xray that supports xray-v1.8 format configurations is [Xray-core v24.11.30](https://github.com/XTLS/Xray-core/releases/tag/v24.11.30). The following versions suggest breaking server and client configurations with the transition to XHTTP. **Conclusion:** I would try to update xray to version [Xray-core v24.11.30](https://github.com/XTLS/Xray-core/releases/tag/v24.11.30), [tun2socks-v2.5.2](https://github.com/xjasonlyu/tun2socks/releases/tag/v2.5.2) synchronously: both on the client and on the server. p.s. I have my own VPS with xray-v24.11.30 (RAM-512MB, 3 clients, REALITY, not Amnezia, not a container) and there are no problems with memory overuse: uptime is more than 1 year. **We are waiting for the developers' decision**.
Author
Owner

@chiploonkar commented on GitHub (Oct 29, 2025):

Thank you @AKotov-dev this helped!

<!-- gh-comment-id:3463511218 --> @chiploonkar commented on GitHub (Oct 29, 2025): Thank you @AKotov-dev this helped!
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#509
No description provided.