<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Aiohttp on zengjinji · Technical Notes</title><link>https://zengjinji.github.io/tags/aiohttp/</link><description>Recent content in Aiohttp on zengjinji · Technical Notes</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Tue, 01 Dec 2026 00:00:00 +0800</lastBuildDate><atom:link href="https://zengjinji.github.io/tags/aiohttp/index.xml" rel="self" type="application/rss+xml"/><item><title>Investigating a Memory Leak in a Python 3 aiohttp Service</title><link>https://zengjinji.github.io/posts/python-aiohttp-memory-leak/</link><pubDate>Tue, 01 Dec 2026 00:00:00 +0800</pubDate><guid>https://zengjinji.github.io/posts/python-aiohttp-memory-leak/</guid><description>&lt;blockquote&gt;&#10;&lt;p&gt;After memory alerts fired on production nodes, we found that the RSS of a Python 3 health check process using aiohttp had kept growing to around 325 GiB. Combining Memray allocation records, heap samples from the original process, and source code comparisons, we traced the leak to the &lt;code&gt;CIMultiDict&lt;/code&gt; constructor in &lt;code&gt;multidict 6.3.1&lt;/code&gt;, which failed to release a reference to the request-header list. After upgrading to &lt;code&gt;multidict 6.7.1&lt;/code&gt; in production, RSS no longer showed sustained growth.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;&lt;code&gt;health_web&lt;/code&gt; is a Python health check script that uses aiohttp.&lt;/p&gt;&#10;&lt;p&gt;When we noticed the production issue, &lt;code&gt;health_web&lt;/code&gt; had been running continuously for about two months. Its process RSS had grown to roughly 325 GiB on each of two ARM64 nodes. We first needed to divert business traffic away from the affected nodes, then preserve the original processes and PIDs for investigation. A restart would release the objects that had accumulated on the heap, and a new process might not reproduce the problem quickly. This investigation therefore required reading &lt;code&gt;/proc&lt;/code&gt; for the original processes and examining their state with tools such as GDB.&lt;/p&gt;</description></item></channel></rss>