<div dir="ltr">Hi Haskell-Cafe,<div><br></div><div>I understand from <a href="https://mail.haskell.org/pipermail/haskell-cafe/2014-June/114763.html">https://mail.haskell.org/pipermail/haskell-cafe/2014-June/114763.html</a> that it is safe to pass ByteArray# objects to FFI calls, using the UnliftedFFITypes language extension. As I understand it, the implicit guarantee is that the RTS will pin the ByteArray#'s address in memory for the duration of the FFI call -- even if the ByteArray# wasn't allocated pinned.</div><div><br></div><div>I'm curious: how does the RTS achieve this "retroactive" pinning? The documentation at <a href="https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC/Pinned">https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC/Pinned</a> suggests that <i>all</i> ByteArrays are allocated pinned to account for the possibility that they will in future be passed to the FFI. Is this really the case? This seems like it forces an unreasonably slow allocator on small (say, ~10-byte) ByteArray allocations where the GC's usual bump-pointer allocator might otherwise be preferable.</div><div><br></div><div>Regards,</div><div>Reiner</div></div>