I’m running mitmdump in upstream mode and use it to block specific requests. After starting mitmdump and browsing several websites, mitmdump consumes over 1.5G of memory. I don’t see that it is leaking (I restart it frequently). I’m curious if there are settings or custom script that I could use to lower the memory usage. I have also seen that it frequently consumes a lot of CPU. Given that the bulk of the traffic is just being sent to an upstream proxy (and some of it dropped), I’d think this would be a very lightweight solution.
/usr/bin/python /usr/local/bin/mitmdump -v -U http://127.0.0.1:8888 -s lib/myscript.py
myscript.py simply uses the request hook to check url patterns and if I want to drop the request it uses:
def request(context, flow):
# some logic to decide if request should be dropped …
I’m on the current release (0.17.1) and have manually applied the patch outlined here (https://github.com/mitmproxy/mitmproxy/commit/02ba76ea0904b15f01956587a6ebbde43ee97909) to get the upstream proxy authentication working. Running on: Ubuntu 14.04.5 LTS
Output from top:
KiB Mem: 4046856 total, 2008332 used, 2038524 free, 22448 buffers
KiB Swap: 0 total, 0 used, 0 free. 294620 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
14808 ubuntu 20 0 2027404 758640 6592 S 124.4 18.7 2:25.57 mitmdump
‘top’ output doesn’t display well here, but it is using over 2G of memory and 124% cpu. I’ve thought of testing with the tip-of-the-tree from source, but a bit afraid of introducing new issues. Any suggestions would be appreciated.