Ticket #9 (new defect)

Opened 6 years ago

External events leak space when unused

Reported by: conal Owned by:
Priority: major Milestone:
Version: Keywords: performance, space leak
Cc:

Description

There is a space leak with the current implementation of external events. Each one has an associated channel that gets filled whether or not anyone is listening. When there are no listeners, the channel just gets filled and not drained. Perhaps the leak could be eliminated with the help of a weak reference. Access the channel's read end via a structure than has an unused strong pointer to the channel. Access its write end via a weak ref. If the read end becomes inaccesible, then GC will (eventually) make the write end inaccesible, so it will stop getting filled and the existing channel content will get reclaimed.

I think this mechanism can be wrapped up as a reusable abstraction that hides the channel entirely.

Note: See TracTickets for help on using tickets.