# Pastebin FXmZ6Ucn import __pypy__ import itertools import psutil from cryptography.hazmat.bindings._openssl import ffi, lib @ffi.callback("void *(size_t, const char *, int)") def malloc(size, path, line): __pypy__.add_memory_pressure(size) return lib.Cryptography_malloc_wrapper(size, path, line) @ffi.callback("void *(void *, size_t, const char *, int)") def realloc(ptr, size, path, line): __pypy__.add_memory_pressure(size) return lib.Cryptography_realloc_wrapper(ptr, size, path, line) @ffi.callback("void(void *, const char *, int)") def free(ptr, path, line): return lib.Cryptography_free_wrapper(ptr, path, line) result = lib.Cryptography_CRYPTO_set_mem_functions(malloc, realloc, free) assert result == 1 from cryptography import x509 from cryptography.hazmat.backends import default_backend CERTIFICATE = """ -----BEGIN CERTIFICATE----- MIIFIjCCBAqgAwIBAgISA/laRm/f3AyE6irg+ZvuUlT3MA0GCSqGSIb3DQEBCwUA MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xNzA0MjAwMjIxMDBaFw0x NzA3MTkwMjIxMDBaMCoxKDAmBgNVBAMTH2NhZGR5LmR5c2Z1bmN0aW9uYWwtdGVz dGluZy5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC5wxihdb52 syQ5iVmMHh6TRS2BBtVM6lzqk2LualJBPVgkzJecrRebC51Abzo1gVDh1orStMzF 3J3L91qYOl9yxh0k46tXEcZwAGr7mhdmP+//wL1Zf4QvHFxVNNgW1wiADeoxQL3G I4KmRE7rQBrTlJxDt0nOV/WKvxHt73Fqab5S2qXMZsclxBwQBoB3rrdx0apgctX6 UBw/t0TskYoJu98Ux574MgNlZQutNmhq5Z/4noEdLF4GtN/Cc5KgCIgQiPXGR8Tk I/awSgQIW4epWa+w5P26gwJuaHZKh6MtU/sZrKy0mC9UCqWLqoZGB9XSTNr9lnx4 vxiyb/0v2eO1AgMBAAGjggIgMIICHDAOBgNVHQ8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fXIG8sP6dNwLADuOhqIw== -----END CERTIFICATE----- """ def work(): x509.load_pem_x509_certificate(CERTIFICATE, default_backend()) def main(): p = psutil.Process() base_memory = p.memory_info().rss for i in itertools.count(): work() if i % 50000 == 0: print(p.memory_info().rss - base_memory) if __name__ == "__main__": main()