haskell / primitive

This package provides various primitive memory-related operations.
Other
114 stars 58 forks source link

Clarify that newly allocated `ByteArray`s/`PrimArray`s are uninitialized #390

Closed konsumlamm closed 1 year ago

konsumlamm commented 1 year ago

I just had a bug, because I assumed ByteArrays/PrimArrays were initialized with zeros. Unfortunately, the documentation didn't mention that they're uninitialized (except for newPrimArray).

andrewthad commented 1 year ago

Thanks! Definitely worth calling this out explicitly in the docs. The worst part is that in something super short running, it ends up filled by zeroes (because the memory pages GHC's runtime requests from the kernel with mmap is zero filled), but then after the first GC, once pages start getting reused, then you get burned.