newArray_ allocates an array full of garbage
In http://www.haskell.org/pipermail/haskell-cafe/2006-December/020115.html Stefan O'Rear points out that newArray_ allocates an array full of garbage. For ST this violates referential transparency, and it presumably also means we are leaking information we shouldn't.
For example, running
import Control.Monad.ST
import Data.Array.ST
import Data.Array
import System.Mem
tickle :: Int
tickle = runST (do {
x <- newArray_ (0,100) ;
(readArray :: STUArray s Int Int -> Int -> ST s Int) x 3
})
main :: IO ()
main = do print $ length (replicate 100000 'a')
performGC
print tickle
produced
$ ./q
100000
46912506425344
Trac metadata
Trac field | Value |
---|---|
Version | 6.6 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |