|
Re: Space leak: msg#00160lang.haskell.glasgow.bugs
Tomasz Zielonka wrote: On Tue, Dec 27, 2005 at 08:12:20PM +0100, Christian Maeder wrote: ok, I could also fix the space leak by defining my own iterate function: myiterate :: (a -> a) -> a -> [a] myiterate f a = a : (myiter f $! f a) main = mapM_ print $ take (n * 5) $ drop (n * 3) $ myiterate succ 1 is also ok. The next problem occurs when I try to use splitAt as in the original DNA example: main = do let (s1, s2) = splitAt (n * 3) $ myiterate succ 1 mapM_ print s1 mapM_ print $ take (n * 5) s2 The above code leaks space! But main = do let s1 = take (n * 3) $ myiterate succ 1 s2 = drop (n * 3) $ myiterate succ 1 mapM_ print s1 mapM_ print $ take (n * 5) s2 does not leak, as long as it is compiled without optimization. (Eliminating the CSE "myiterate succ 1" makes it leak.) Could optimization be improved? Cheers Christian
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Signal inconsistency between GHC and GHCi, Sven Panne |
|---|---|
| Next by Date: | Re: [GHC] #414: GHC does not eforce that Main exports main, GHC |
| Previous by Thread: | Re: Space leak, Tomasz Zielonka |
| Next by Thread: | GADTs and type synonyms, Ralf Hinze |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |