Ticket #3039 (closed merge: fixed)
strange space usage
| Reported by: | igloo | Owned by: | igloo |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.10.2 |
| Component: | Compiler | Version: | 6.10.1 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Difficulty: | Unknown | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
This program:
module Main (main) where
import System.IO.Unsafe
main :: IO ()
main = do writeFile "wibbleflibble" (replicate 100 'z')
bs <- getCs $ g $ replicate 1000000 "flibble"
print $ last bs
getCs :: [FilePath] -> IO String
getCs [] = return ""
getCs (c : cs) = do x <- readFile c
xs <- unsafeInterleaveIO $ getCs cs
return (x ++ xs)
g :: [FilePath] -> [FilePath]
g is = map f is
f :: FilePath -> FilePath
f fn = "wibble" ++ fn
when run:
$ ghc -fforce-recomp -Wall --make -O2 -prof -auto-all z.hs -o z $ ./z +RTS -h -p
shows that around 100k is used by f (h.png). Running with
$ ./z +RTS -hcf -hy -p
shows that it is all of type [] (hcf_hy.png). That seems like a large amount of space for a 13 character filename, so it smells to me like something is wrong somewhere.
If we inline g:
module Main (main) where
import System.IO.Unsafe
main :: IO ()
main = do writeFile "wibbleflibble" (replicate 100 'z')
bs <- getCs $ map f $ replicate 1000000 "flibble"
print $ last bs
getCs :: [FilePath] -> IO String
getCs [] = return ""
getCs (c : cs) = do x <- readFile c
xs <- unsafeInterleaveIO $ getCs cs
return (x ++ xs)
f :: FilePath -> FilePath
f fn = "wibble" ++ fn
then it all disappears (h2.png).
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

