Skip to content

Memory leak in node #10

@sloosch

Description

@sloosch

Hi,

noticed that Aff-Bus is leaking slowly memory in a toy project i have. Here is a minimal working example which shows the leakage quite well (on my machine after 30sec 500MB and rising):

loopy :: BusRW Unit -> Aff _ Unit
loopy bus = do
  _ <- Bus.read bus
  _ <- forkAff $ loopy bus
  Bus.write unit bus
  
main :: forall e. Eff _ Unit
main = launchAff_ $ do
  bus <- Bus.make
  _ <- forkAff $ loopy bus
  Bus.write unit bus

I have only tested this with node (v8.11.1) not in a browser.

After playing around a bit, i noticed that the problem seems to be the traverse with Either here https://github.com/slamdata/purescript-aff-bus/blob/master/src/Control/Monad/Aff/Bus.purs#L64

Replacing the traverse with pattern-matching seems to fix the problem e.g.

attempt (takeVar cell) >>= case _ of
    Left _ -> pure unit
    Right res -> do ....

Can anyone confirm the leakage? Is this even a problem in Aff-Bus or is it Aff making problems?

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