Prompt: This async Python server has a memory leak that only manifests under high concurrency. The leak grows at ~50MB/hour. Identify likely causes and write diagnostic code to find the exact source. Generated: This async Python server has a memory leak that only manifests under high concurrency. The leak grows at ~50MB/hour. Identify likely causes and write diagnostic code to find the exact source. Here's a thinking process that leads to the suggested solution: 1. **Understand the Goal:** The user wants to identify and diagnose a memory leak in an asynchronous Python server (likely using `asyncio` or frameworks like FastAPI/Starlette/aiohttp) that occurs specifically under high concurrency, growing at approximately 50MB/hour. I need to provide potential causes and specific diagnostic code to pinpoint the issue. 2. **Analyze the Symptoms:** * **Environment:** Async Python Server (`asyncio`, `uvicorn`, etc.). * **Condition:** High concurrency (many concurrent tasks). * **Symptom:** Memory leak (~50MB/hour). * **Nature:** "Leak" implies objects aren't being garbage collected when they should be. In async contexts, this is often related to reference cycles, event loops holding references, or unclosed resources. 3.