possible memory leak related to the Date header #2496
Unanswered
stefanoterna
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
while I was load testing my application, and doing some
tracemalloc
, I noticed a continue increase in the count of references and in the allocated memory related to the following:The code at
usr/local/lib/python3.12/email/utils.py:278
is in the python function format_datetime.This is why I guess the problem is related to unreleased references to the Date header:
uvicorn/uvicorn/server.py
Line 235 in fe39100
Minimum reproducible example
So I started doing some experiments with a simple application with a single post function that just returns "ok":
This is the code:
Testing with randomicity of message rate and intervals
These experiments are performed with a Python 3.12.3 client doing the following in an infinite loop:
SLEEP_TIMES = [0.1, 0.2, 0.3, 0.05, 0.01]
/msg
endpoint viarequests.post
(no persistent connection, no connection pool) for the selected time interval at the selected message rate, randomly selecting a payload from a listHeaders
headers = {'cache-control': 'no-cache', 'content-type': 'application/x-www-form-urlencoded'}
, asapplication/x-www-form-urlencoded
is a requirement I have from real-world clients.The use of random is properly seeded for reproducibility.
Randomized experiments outcome
These are the outcomes from tracemalloc (
['abc', 'linecache', 'tracemalloc', 'logging']
are excluded from tracing) :Randomized experiments considerations
2024-10-27 04:00
now
variable from email.utilsTesting without randomicity of message rate and intervals
These experiments are performed with a Python 3.12.3 client doing the following in an infinite loop:
/msg
endpoint viarequests.post
(no persistent connection, no connection pool)headers = {'cache-control': 'no-cache', 'content-type': 'application/x-www-form-urlencoded'}
Not randomized experiments outcome
Not randomized experiments considerations
2024-10-25 08:00
to2024-10-25 10:00
2024-10-24 200:00
, both in total memory and email.utilsFurhter considerations and research
When running the same server in Hypercorn, there is no trace of the email.utils unreleased reference
Thanks for your attention and help!
Beta Was this translation helpful? Give feedback.
All reactions