dvde: > > Don Stewart schrieb: >> It is not possible to write a modifyIORef that *doesn't* leak memory! >> > Why? Or can one read about it somewhere?
Try writing a version of this program, using modifyIORef only, such that it doesn't exhaust the heap: import Data.IORef import Control.Monad import System.IO.Unsafe ref :: IORef Int ref = unsafePerformIO $ newIORef 0 {-# NOINLINE ref #-} main = do modifyIORef ref (\a -> a + 1) main Run it in a constrained environment, so you don't thrash: $ ./A +RTS -M100M Heap exhausted; Current maximum heap size is 99999744 bytes (95 MB); use `+RTS -M<size>' to increase it. The goal is to run in constant space. -- Don _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe