[Haskell-cafe] Array, Vector, Bytestring

Alfredo Di Napoli alfredo.dinapoli at gmail.com
Wed Jul 10 11:20:57 CEST 2013

Hello Bas,

sorry for being unclear. What you say is correct, I was referring (and I
realised this after posting :D ) that the real
annoying thing is fragmentation in memory. Due to the fact the GC can't
move those objects, if we have long running
processes our memory will become more and more fragmented, correct? :(


On 10 July 2013 08:25, Bas van Dijk <v.dijk.bas at gmail.com> wrote:

> On 10 July 2013 08:57, Alfredo Di Napoli <alfredo.dinapoli at gmail.com>
> wrote:
> >
> >> 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.
> Being "pinned" doesn't prevent an object from being garbage collected.
> 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
> > I assume that working with vector remove the problem, correct?
> There wasn't a problem in the first but note that a Storable Vector is
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130710/84dacc67/attachment.htm>

More information about the Haskell-Cafe mailing list