This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sophia2
Recipients asvetlov, sophia2, yselivanov
Date 2020-09-03.03:24:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1599103455.66.0.578420174204.issue41699@roundup.psfhosted.org>
In-reply-to
Content
The below example leaks ~20 megabytes of memory. The amount leaked is related to both the number of items in the list and the number of times `run_in_executor` is called.

```
import asyncio

def leaker():
    x = list(range(int(1000)))
    1/0

async def function():
    loop = asyncio.get_running_loop()
    for i in range(10000):
        loop.run_in_executor(None, leaker)
```
at this point, `ps -o rss -p {pid}` outputs about 10MB

after invoking this:
```
asyncio.run(function())
```
Memory jumps to about 94MB, and doesn't return.

The lists don't show up in `gc.get_objects()`, but the amount of memory leaked does increase (though not proportionately) when the lists increase in size.

Note - this doesn't happen if `run_in_executor` is `await`ed immediately, but it does still occur if we e.g. put the future in a dictionary and then `await` the results later.
The leak still occurs on my machine if the `1/0` is omitted, but not on a colleague's.

We're pretty confused as to why this happens, and would appreciate any help.
History
Date User Action Args
2020-09-03 03:24:15sophia2setrecipients: + sophia2, asvetlov, yselivanov
2020-09-03 03:24:15sophia2setmessageid: <1599103455.66.0.578420174204.issue41699@roundup.psfhosted.org>
2020-09-03 03:24:15sophia2linkissue41699 messages
2020-09-03 03:24:15sophia2create