
13 Nov
2010
13 Nov
'10
11:55 a.m.
I've came upon very a strange situation with memory consumption. The smallest test case I've been able to come up with is the following: import Data.List wtf d = head . dropWhile (< 10^100) . map (*d) $ enumFrom 2 main = do print $ wtf 1 print $ wtf 2 -- Everything is ok without this line Expected result is that program runs in constant space. What really happening is that the program consumes memory until killed. If second call to wtf is removed, memory usage stays constant while the program is working. The problem is in that list returned from enumFrom is being saved between calls to wtf. Is there any way to overcome this? -- Regards, Petr