Skip to content

Mild memory leak in wake-on-network #46

@ecpeterson

Description

@ecpeterson

When a message arrives at an inbox, the courier notifies all the actors in its listeners hash which are keyed on that inbox and clears them from the hash. A process typically adds itself to that set using wake-on-network, where it potentially supplies a lengthy list of inboxes for which it would like to wake up. This means that in the following scenario:

(wake-on-network inbox-A inbox-B)
;; P appended to listener lists for P, inbox-A, and inbox-B
;; message arrives at inbox-A, listener list for inbox-A is cleared, P wakes up
(wake-on-network inbox-A inbox-B)
;; P appended to listener lists for P, inbox-A, and inbox-B

the listener list for inbox-B now includes P twice. This pattern is fairly common, e.g., it happens within with-replies. In fact, if a message arrives at P's public inbox, then inbox-A and inbox-B will both reference P twice after the second call to wake-on-network, so this over-recording can happen without any termination in sight.

This isn't a huge leak of resources (yet), but it is unsightly and would be solved by sorting the set of listeners as something like a set (/ hash) rather than as a list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions