Author martius
Recipients martius
Date 2015-01-09.17:16:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1420823775.21.0.0191485458241.issue23209@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,

I would like to submit 3 trivial modifications which break a cycle each. It is not much, but those three cycles caused a lot of objects to be garbage collected. They can now be freed using the reference counting mechanism, and therefore, reduce the latency that may be involved by the work of the garbage collector in a long living process.

In asyncio/base_subprocess.py:
WriteSubprocessPipeProto.proc is a reference to a BaseSubprocessTransport object, which holds a reference to the WriteSubprocessPipeProto in self._protocol.

I break the cycle in the protocol at the end of connection_lost().

In asyncio/futures.py:
wrap_future() defines a lambda which uses a variable defined in the function, therefore creating a closure, referencing the wrap_future() function and creating a cycle.

In the (really trivial) patch, the lambda uses the argument "future" instead of the "fut" variable defined in a closure. The closure is not needed anymore.

This single cycle is very common, because caused when one uses getaddrinfo().

In asyncio/selectors.py:
_BaseSelectorImpl._map keeps a reference to the _SelectorMapping object, which also references the selector with _SelectorMapping._selector.

The reference to the map in the selector is cleared once the selector is closed.
History
Date User Action Args
2015-01-09 17:16:15martiussetrecipients: + martius
2015-01-09 17:16:15martiussetmessageid: <1420823775.21.0.0191485458241.issue23209@psf.upfronthosting.co.za>
2015-01-09 17:16:15martiuslinkissue23209 messages
2015-01-09 17:16:14martiuscreate