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 EmperorBale
Recipients EmperorBale, asvetlov, valid22, yselivanov
Date 2020-09-17.16:52:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1600361532.62.0.641004320219.issue41794@roundup.psfhosted.org>
In-reply-to
Content
Ok since nobody is replying, the bug seems to be that if the asyncio server sends data, and I do not use s.recv() to clear the buffer, and I use s.close() instead, a reference to handle_echo is kept and is never deleted.

Using gc.collect() does delete the leaked object. 

The socket that you use to connect to the server seems to also determine whether the bug works, like how I can not do it when I create the connection on my windows computer, but the bug is triggered when I do it on my ubuntu server. I should also mention that I am running the asyncio server on my ubuntu server, on python 3.8.

Here is output of the bug happening.
FROM CLIENT ON MY WINDOWS COMPUTER ON PY3.8:
>>> s = socket.socket()
>>> s.connect(("x.x.x.x", 8888))
>>> s.send(b"test")
4
# Wait for server to send data, but dont use s.recv(), just assume
>>> s.close()
Server output:
Received 'test' from ('x.x.x.x', 42241)
Send: 'test'
connection lost
DELETED OBJECT

After connection was lost, DELETED OBJECT was printed, so everything worked fine. But when I create the socket in a different environment, such as on ubuntu python 3.8:
Client side code (exact same as before):
>>> s = socket.socket()
>>> s.connect(("x.x.x.x", 8888))
>>> s.send(b"test")
4
# Wait for server to send data, but dont use s.recv(), just assume
>>> s.close()
Server side output:
Received 'test' from ('x.x.x.x', 42249)
Send: 'test'
connection lost

We can see that connection lost was printed, but DELETED OBJECT was not. This is evidence that there is a memory leak bug with asyncio.start_server
History
Date User Action Args
2020-09-17 16:52:12EmperorBalesetrecipients: + EmperorBale, asvetlov, yselivanov, valid22
2020-09-17 16:52:12EmperorBalesetmessageid: <1600361532.62.0.641004320219.issue41794@roundup.psfhosted.org>
2020-09-17 16:52:12EmperorBalelinkissue41794 messages
2020-09-17 16:52:11EmperorBalecreate