Commit 2b6b2a78 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Add a test for returning memory to the OS

parent 845aff2a
......@@ -91,3 +91,5 @@ test('exec_signals', [
cmd_prefix('$MAKE exec_signals-prep && ./exec_signals_prepare'),
extra_clean(['exec_signals_child', 'exec_signals_prepare'])
], compile_and_run, [''])
test('return_mem_to_os', normal, compile_and_run, [''])
import Control.Concurrent
import System.IO
import System.Mem
main :: IO ()
main = do hSetBuffering stdout LineBuffering
mapM_ doIter [1..3]
doIter :: Int -> IO ()
doIter n = do putStrLn ("Iteration " ++ show n)
let xs = [n .. 1000000 + n]
putStrLn ("Last: " ++ show (last xs))
putStrLn "GC 1 start"
performGC
putStrLn "GC 1 done"
putStrLn ("Head: " ++ show (head xs))
putStrLn "GC 2 start"
performGC
putStrLn "GC 2 done"
Iteration 1
Last: 1000001
GC 1 start
GC 1 done
Head: 1
GC 2 start
GC 2 done
Iteration 2
Last: 1000002
GC 1 start
GC 1 done
Head: 2
GC 2 start
GC 2 done
Iteration 3
Last: 1000003
GC 1 start
GC 1 done
Head: 3
GC 2 start
GC 2 done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment