logo       

memory allocation (non) bug: msg#00063

lang.haskell.glasgow.bugs

Subject: memory allocation (non) bug

Running primes1 from the following code in "The Haskell Road to Logic, Maths and Programming"

ldp :: Integer -> Integer
ldp n = ldpf primes1 n

ldpf :: [Integer] -> Integer -> Integer
ldpf (p:ps) n | rem n p == 0 = p
| p^2 > n = n
| otherwise = ldpf ps n

primes1 :: [Integer]
primes1 = 2 : filter prime [3..]

prime :: Integer -> Bool
prime n | n < 1 = error "not a positive integer"
| n == 1 = False
| otherwise = ldp n == n

I got the following message after a lot of lines of output, and a very long run.

,100038989,100038997,100039003,100039007,100039019,100039031,100039039
<interactive>: internal error: memory allocation failed (requested 2097152 bytes)
Please report this as a bug to glasgow-haskell-bugs@xxxxxxxxxxx,
or http://www.sourceforge.net/projects/ghc/

I am using a 2 GHz G5 iMac with 1 Gbyte RAM, OS X 10.4.5 and GHC(I) 6.4.1. Further I can hardly consider this a bug as HUGS on a PC gave up with a garbage collection error when the primes had reached only just over three million. Thought you should know anyway.

Iain


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise