Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak when using mergeSources #54

Open
francisdb opened this issue Sep 6, 2018 · 1 comment
Open

Memory leak when using mergeSources #54

francisdb opened this issue Sep 6, 2018 · 1 comment
Labels

Comments

@francisdb
Copy link

francisdb commented Sep 6, 2018

I'm quite new to Haskell but I guess this is not supposed to happen

Using the example code below when using the plain conduit source the memory usage stays constant but with mergeSources it keeps growing. Even when doing a merge with a single source.

main :: IO ()
main = do
  let
    sqrts = yieldMany [1..] .| mapC sqrt .| printC
  source <- mergeSources (replicate 2 sqrts) 16
  -- source <- return sqrts
  runConduitRes $ source .| sinkNull
@qnikst
Copy link
Collaborator

qnikst commented Jul 30, 2023

Thanks for the report! Indeed it looks like a problem somewhere.

A very similar program that does basically the same (except some additional actions for resource managing) has the correct behaviour:

import Control.Concurrent
import Control.Concurrent.STM.TBMChan
import Data.Conduit
import Data.Conduit.TMChan
import qualified Data.Conduit.Combinators as C
import qualified Data.Conduit.List as CL
import Control.Monad.Trans.Resource
import Control.Monad

main :: IO ()
main = do
  x <- newTBMChanIO  16
  forkIO $ runConduit $ C.yieldMany [1..] .| CL.map sqrt .| sinkTBMChan x
  forkIO $ runConduit $ C.yieldMany [1..] .| CL.map sqrt .| sinkTBMChan x
  runConduit $ sourceTBMChan x .| C.print

We will try to dig further into the problem.

@qnikst qnikst added the bug label Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants