30 Aug 2012 13:29
Small Int and Char closures in GHCi
Joachim Breitner <mail <at> joachim-breitner.de>
2012-08-30 11:29:23 GMT
2012-08-30 11:29:23 GMT
Hi, I am preparing a talk about the details of how data and programs look in memory in Haskell (well, GHC). When explaining the memory consumption of a large String, I wanted to show the effect of short-int-replacement that happens in http://hackage.haskell.org/trac/ghc/browser/rts/sm/Evac.c#L550 I use my ghc-heap-view-package to observe the heap. This programs shows the effect: import GHC.HeapView import System.Mem main = do let hallo = "hallo" mapM_ (\x -> putStrLn $ show x ++ ": " ++ show (asBox x)) hallo performGC mapM_ (\x -> putStrLn $ show x ++ ": " ++ show (asBox x)) hallo gives, as expected: $ ./SmallChar 'h': 0x00007f2811e042a8/1 'a': 0x00007f2811e08128/1 'l': 0x00007f2811e09ef0/1 'l': 0x00007f2811e0bcd8/1 'o': 0x00007f2811e0db10/1(Continue reading)
RSS Feed