#2762: Excessive heap usage
---------------------------------+------------------------------------------
    Reporter:  igloo             |       Owner:                  
        Type:  bug               |      Status:  new             
    Priority:  normal            |   Milestone:  6.10.2          
   Component:  Compiler          |     Version:  6.11            
    Severity:  normal            |    Keywords:                  
  Difficulty:  Unknown           |    Testcase:                  
Architecture:  Unknown/Multiple  |          Os:  Unknown/Multiple
---------------------------------+------------------------------------------
 With `Main.hs`:
 {{{
 module Main (main) where

 import InputOutput

 main :: IO ()
 main = do
           let content1 = concat (replicate 1000000 "1x") ++ "0"
           let i1 = fst $ input content1
           view i1

           let content2 = concat (replicate 1000001 "1y") ++ "0"
           let i2 = fst $ input content2
           view i2

 view :: [Char] -> IO ()
 view [] = return ()
 view (i : is) = i `seq` view is
 }}}
 and `InputOutput.hs`:
 {{{
 module InputOutput (input) where

 class InputOutput a where
     input :: String -> (a, String)

 instance InputOutput Char where
     input (x : bs) = (x, bs)

 instance InputOutput a => InputOutput [a] where
     input ('0':bs) = ([], bs)
     input ('1':bs) = case input bs of
                      (x, bs') ->
                          case input bs' of
                          ~(xs, bs'') -> (x : xs, bs'')
 }}}
 according to
 {{{
 ghc -O -prof -auto-all --make Main.hs -fforce-recomp
 ./Main +RTS -h
 }}}
 heap usage goes up to about 20M with the HEAD, but only about 200 bytes
 with 6.8.2.

 This is with 6.11.20081108, but I started investigating with the HEAD when
 I saw similar problems with more-or-less 6.10.1.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2762>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to