{"action":"closed","issue":{"url":"https://api.github.com/repos/atzeus/FRPNow/issues/14","labels_url":"https://api.github.com/repos/atzeus/FRPNow/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/atzeus/FRPNow/issues/14/comments","events_url":"https://api.github.com/repos/atzeus/FRPNow/issues/14/events","html_url":"https://github.com/atzeus/FRPNow/issues/14","id":99878164,"number":14,"title":"Huge memory consumption when using scanl/callIOStream to sum integers","user":{"login":"ocharles","id":20878,"avatar_url":"https://avatars.githubusercontent.com/u/20878?v=3","gravatar_id":"","url":"https://api.github.com/users/ocharles","html_url":"https://github.com/ocharles","followers_url":"https://api.github.com/users/ocharles/followers","following_url":"https://api.github.com/users/ocharles/following{/other_user}","gists_url":"https://api.github.com/users/ocharles/gists{/gist_id}","starred_url":"https://api.github.com/users/ocharles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocharles/subscriptions","organizations_url":"https://api.github.com/users/ocharles/orgs","repos_url":"https://api.github.com/users/ocharles/repos","events_url":"https://api.github.com/users/ocharles/events{/privacy}","received_events_url":"https://api.github.com/users/ocharles/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-08-09T09:18:03Z","updated_at":"2015-08-24T12:03:49Z","closed_at":"2015-08-24T12:03:49Z","body":"\r\n![2015-08-09-101932_1402x941_scrot](https://cloud.githubusercontent.com/assets/20878/9154301/296c9976-3e80-11e5-8bb0-ada53768e9c4.png)\r\n```haskell\r\nmodule Main where\r\n\r\nimport Control.Monad\r\nimport Control.Concurrent\r\nimport Control.FRPNow\r\n\r\nmain :: IO ()\r\nmain =\r\n  runNowMaster\r\n    (do (evs,fire) <- callbackStream\r\n        async (replicateM_\r\n                 n\r\n                 (do threadDelay 100\r\n                     fire 1))\r\n        sum <- sample (scanlEv (+) 0 evs)\r\n        callIOStream print sum\r\n        fmap void (sample (next (filterEs (>= n) sum))))\r\n    where n = 100000\r\n```\r\n\r\nWhen ran:\r\n\r\n```\r\n   5,424,406,728 bytes allocated in the heap\r\n  18,516,064,696 bytes copied during GC\r\n     400,022,240 bytes maximum residency (95 sample(s))\r\n       5,068,960 bytes maximum slop\r\n             786 MB total memory in use (0 MB lost due to fragmentation)\r\n\r\n                                     Tot time (elapsed)  Avg pause  Max pause\r\n  Gen  0     10364 colls,     0 par    0.970s   0.970s     0.0001s    0.0004s\r\n  Gen  1        95 colls,     0 par   19.331s  19.348s     0.2037s    0.4301s\r\n\r\n  INIT    time    0.001s  (  0.001s elapsed)\r\n  MUT     time    9.577s  ( 23.963s elapsed)\r\n  GC      time   10.713s  ( 10.725s elapsed)\r\n  RP      time    0.000s  (  0.000s elapsed)\r\n  PROF    time    9.587s  (  9.594s elapsed)\r\n  EXIT    time    0.003s  (  0.004s elapsed)\r\n  Total   time   29.885s  ( 34.693s elapsed)\r\n\r\n  %GC     time      35.8%  (30.9% elapsed)\r\n\r\n  Alloc rate    566,387,833 bytes per MUT second\r\n\r\n  Productivity  32.1% of total user, 27.6% of total elapsed\r\n```"}}