Skip to content

Conversation

@github-actions
Copy link

related: #56641

When I performed the same memray inspection on the latest version that includes both fixes, the first issue was clearly resolved, but the second issue still persists.
memray1.html

When a Client object is created, ctx = ssl.create_default_context(cafile=ca_file) continues to be executed repeatedly, which accumulates in memory and causes a memory leak. (It appears to be allocated as a C language object and remains in memory regardless of Python object GC)

This PR uses caching to prevent the SSL context object from being recreated.

Here are the results after running for two hours with this change. The memory usage, which was previously growing to tens of MBs, now stabilizes at approximately 700KB.
memray2.html
(cherry picked from commit 7369e46)

Co-authored-by: Jeongwoo Do 48639483+wjddn279@users.noreply.github.com

related: #56641

When I performed the same memray inspection on the latest version that includes both fixes, the first issue was clearly resolved, but the second issue still persists.
[memray1.html](https://github.com/user-attachments/files/23160226/memray1.html)

When a Client object is created, `ctx = ssl.create_default_context(cafile=ca_file)` continues to be executed repeatedly, which accumulates in memory and causes a memory leak. (It appears to be allocated as a C language object and remains in memory regardless of Python object GC)

This PR uses caching to prevent the SSL context object from being recreated.

Here are the results after running for two hours with this change. The memory usage, which was previously growing to tens of MBs, now stabilizes at approximately 700KB.
[memray2.html](https://github.com/user-attachments/files/23160405/memray2.html)
(cherry picked from commit 7369e46)

Co-authored-by: Jeongwoo Do <48639483+wjddn279@users.noreply.github.com>
@kaxil kaxil marked this pull request as ready for review October 27, 2025 22:56
@potiuk potiuk merged commit 88ad427 into v3-1-test Oct 27, 2025
21 checks passed
@potiuk potiuk deleted the backport-7369e46-v3-1-test branch October 27, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants