memory allocation (non) bug

Iain Gray iaingray at ednet.co.uk
Mon Feb 20 14:18:02 EST 2006


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 at haskell.org,
     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



More information about the Glasgow-haskell-bugs mailing list