trojan-gfw / trojan

An unidentifiable mechanism that helps you bypass GFW.
https://trojan-gfw.github.io/trojan/
GNU General Public License v3.0
18.84k stars 3.02k forks source link

[BUG]Memory leak #625

Open MeIsReallyBa opened 2 years ago

MeIsReallyBa commented 2 years ago

Trojan Version Trojan 1.16.0 Describe the bug

On a padavan firmware router running a linux 4.4 kernel, I found that trojan's memory usage would only go down very slowly in some cases. If I just do some simple web speed testing, the memory usage will drop quickly after the speed testing is done. It seems that the memory isn't free properly after a lot of new connections are made.

To Reproduce

  1. Trojan runs in nat mode, and all traffic under the router is redirected to the trojan process using iptables
  2. The lan device under the router runs a p2p downloader
  3. trojan will consume almost all memory

Sent by cat/$pid/maps, the upper bound of the heap area of ​​the trojan process will hardly be changed after several hours. From my point of view, it seems that the memory allocated by the programmer himself has not been properly free in these cases.

Expected behavior Disconnected from the network, after a few hours, trojan's memory usage did not decrease.

Logs If applicable, add logs to help explain your problem.

Environment A padavan firmware router running a linux 4.4 kernel

Additional context

I also tried to run trojan in client mode on the router, and then let the computer on the LAN connect to trojan and perform p2p download, and got the same result.

MeIsReallyBa commented 2 years ago

 After using hanwckf's static version, the memory leak issue disappeared. The gcc version in padavan is gcc7 while hanwckf's static version is using gcc 10. Is it because the gcc version used in padavan too old caused the memory leak?

https://github.com/hanwckf/Trojan-pdv-build