import asyncio async def gen(): _ = [1] * 100000 # a large object yield yield 666 print('func returned!') # "666" can't be yielded, so the function will never return. async def loop(): q = gen() await q.__anext__() await q.asend(123456) # "q" should be cleaned by GC, and return the memory back to system, # but actually not. async def main(): for _ in range(1000): await loop() input() # check the memory usage, Python uses about 700MiB+ memory,. asyncio.run(main())