From Python3.8 to Python3.10: Our Journey Through a Memory Leak
Dec 15, 2025Jay Patel

Summary
This post details the debugging process for a Python memory leak that occurred after upgrading from Python 3.8 to 3.10. It highlights the use of a custom tracemalloc-based memory profiling tool and the identification of an incompatibility between gevent's monkey patching and urllib3's connection pooling (specifically weakref.finalize) as the root cause. The solution involved downgrading urllib3 to 1.26.15. Additionally, it describes a challenge encountered with gunicorn's 'preload' setting when attempting to use signal handlers for profiling.