[GHC] #12889: memory leak
GHC
ghc-devs at haskell.org
Mon Nov 28 16:07:54 UTC 2016
#12889: memory leak
-------------------------------------+-------------------------------------
Reporter: zoranbosnjak | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
This simple test program leaks memory for no obvious reason.
{{{#!hs
module Main where
import Control.Monad
import Control.Monad.Trans.Reader
main :: IO ()
main = do
runReaderT task ()
main
task :: ReaderT () IO ()
task = forM_ [(1::Integer)..] $ \cnt -> do
return cnt
}}}
However, there are some minor changes that (each individual change alone)
make this program run in constant memory.
1. If I remove
{{{#!hs
module Main where
}}}
2. If I remove recursive call to main
3. If I put task definition under the scope of main, like so
{{{#!hs
module Main where
import Control.Monad
import Control.Monad.Trans.Reader
main :: IO ()
main = do
runReaderT task ()
main
where
task :: ReaderT () IO ()
task = forM_ [(1::Integer)..] $ \cnt -> do
return cnt
}}}
Any of the changes above make the program run OK, but I belive that this
should be also true for the original test program. I am not sure where the
problem is (if at all), but it's extremely difficult to isolate this kind
of problem in the real application.
Please check if anything can be done on the compiler or runtime to prevent
this kind of problems.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12889>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list