#2332: Can't allocate 4 gigs of RAM
-------------------------------+--------------------------------------------
 Reporter:  mightybyte         |          Owner:  simonmar      
     Type:  bug                |         Status:  new           
 Priority:  normal             |      Milestone:  6.10.1        
Component:  Compiler           |        Version:  6.8.2         
 Severity:  normal             |     Resolution:                
 Keywords:  memory allocation  |     Difficulty:  Unknown       
 Testcase:                     |   Architecture:  x86_64 (amd64)
       Os:  Linux              |  
-------------------------------+--------------------------------------------
Changes (by igloo):

  * owner:  => simonmar
  * difficulty:  => Unknown
  * milestone:  => 6.10.1

Comment:

 The programs are
 {{{
 import Data.Word
 import Data.Array.IO
 import Data.Array
 import Data.Int

 main = do
     a <- newArray_ (0, 2^32-1) :: IO (IOUArray Int Word8)
     print =<< a `readArray` (2^32-1)
     return ()
 }}}
 and
 {{{
 module Main where

 import Data.Array.IO
 import Data.Array.Storable
 import Data.Int
 import IO

 buildTable1 :: Int -> IO (IOUArray Int Int8)
 buildTable1 size = newArray (0,size-1) 0

 buildTable2 :: Int -> IO (StorableArray Int Int8)
 buildTable2 size = newArray (0,size-1) 0

 go arr = do str <- getLine
             val <- readArray arr (read str)
             print val
             writeArray arr (read str) (val+1)
             go arr

 --size = 4294967296 -- 4 * 2^30 (too big)
 --size = 4294907296 -- Main: internal error...
 size = 4290967296 -- works

 main = do
   hSetBuffering stdout NoBuffering
   print $ ("Building table...",size)
   arr <- buildTable2 size
   putStrLn ""
   putStrLn "Ready."
   go arr
 }}}
 Giving it to you, Simon, as I think you have or will have a machine with
 enough RAM to try to reproduce it!

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2332#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to