From 74aeb3ae4cf9091c3bb9c5c4eb9aed9c4de896fc Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 29 Dec 2020 01:16:55 +0100 Subject: [PATCH] add memory leak detect script for certificate generation, refs #4368 --- test/helper_tools/memoryleak2.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/helper_tools/memoryleak2.py diff --git a/test/helper_tools/memoryleak2.py b/test/helper_tools/memoryleak2.py new file mode 100644 index 000000000..26fa742d9 --- /dev/null +++ b/test/helper_tools/memoryleak2.py @@ -0,0 +1,21 @@ +import secrets +from pathlib import Path + +import objgraph + +from mitmproxy import certs + +if __name__ == "__main__": + store = certs.CertStore.from_store(path=Path("~/.mitmproxy/").expanduser(), basename="mitmproxy", key_size=2048) + store.STORE_CAP = 5 + + for _ in range(5): + store.get_cert(commonname=secrets.token_hex(16).encode(), sans=[], organization=None) + + objgraph.show_growth() + + for _ in range(20): + store.get_cert(commonname=secrets.token_hex(16).encode(), sans=[], organization=None) + + print("====") + objgraph.show_growth()