mitmproxy: Memory Leak in WireGuard Mode
Problem Description
WireGuard and Windows Proxy Mode have a memory leak somewhere.
Steps to reproduce the behavior:
python -m http.servermitmdump --mode osproxy:curl(or WireGuard)while true: curl http://127.0.0.1:8000/
@decathorpe suspects TcpStream.read() 😃
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (16 by maintainers)
Should be fixed here then: https://github.com/mitmproxy/mitmproxy_rs/blob/main/mitmproxy-rs/src/tcp_stream.rs#L47
If noone can repro, let’s close this? 😃
Damn 😮 you figured it out! ✨ ✨
I suspected that something like this might be the cause of the problem - I saw similar issue reports where holding the GIL or not made the difference … but it didn’t dawn on me that the construction of the
PyBytesmight also be affected here.I applied the change you suggested (making sure there’s no reference to the
PyByteson the Rust side remaining after the GIL is held), and the memory leak seems to be gone. Previously, my benchmark workload resulted in memory usage growing up to ~2.6 GB, but now it tops out at ~200 MB and drops back down to ~13 MB after the last connection is closed. Meh, that was a lot of time I wasted on debugging this issue 😆