On 10 July 2013 08:57, Alfredo Di Napoli <alfredo.dinapoli@gmail.com> wrote:Being "pinned" doesn't prevent an object from being garbage collected.
>
>> To make the transition easier I have an experimental library which
>> defines a ByteString as a type synonym of a Storable.Vector of Word8
>> and provides the same interface as the bytestring package:
>>
>> https://github.com/basvandijk/vector-bytestring
>
>
> That's interesting Bas. What bothers me about ByteStrings is that they need
> to be "pinned" inside the heap,
> preventing the GC from collecting them.
It just means that the GC won't move the object around so that foreign
code can reliably reference the object while the GC is running:
http://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC/Pinned
There wasn't a problem in the first but note that a Storable Vector is
> I assume that working with vector remove the problem, correct?
implemented in the same way as a ByteString: a ForeignPtr and a
length*
I hope I have now improved your sleep quality ;-)
Cheers,
Bas
* A ByteString also contains an offset but vector modifies the pointer
in the ForeignPtr instead so we safe an Int there.