When a proactive TLS handshake performed by loop.create_connection() fails (e.g. with ssl.SSLCertVerificationError: CERTIFICATE_VERIFY_FAILED).
The objects are only freed by the cyclic garbage collector, never by reference counting.
The same scenario under uvloop shows no such cycle.
If you clear the traceback from the exception object, the memory stops flowing.
3. Hey, it's not really a leak, because sooner gc will collect those objects. But, if you don't mind i can work on this
I completely agree that this isn’t exactly a leak. But in a high‑load application, you want to avoid running the gc. It would be great if you could resolve this case.
Activity
rus1g commented on Oct 9, 2026
Check the small monkeypatch, after which memory leaks stopped. I hope this will help in finding the problem.
sergey-miryanov commented on Oct 9, 2026
@deadlovelll You may be interested in #142516
rus1g commented on Oct 10, 2026
I completely agree that this isn’t exactly a leak. But in a high‑load application, you want to avoid running the gc. It would be great if you could resolve this case.
gh-159049: Fix reference cycles after a failed TLS handshake in async…
[3.15] gh-159049: Fix reference cycles after a failed TLS handshake i…
[3.14] gh-159049: Fix reference cycles after a failed TLS handshake i…