3 ms·
AFAIK ByteString suffers this problem: substrings will prevent their whole array from being GCed. By default, data read from files, stdin, etc. is split into 6
by chriswarbo 6y ago
AFAIK ByteString suffers this problem: substrings will prevent their whole array from being GCed.
By default, data read from files, stdin, etc. is split into 64k chunks (e.g. see functions like 'hGetN' in http://hackage.haskell.org/package/bytestring-0.9.2.1/docs/src/Data-ByteString-Lazy.html http://hackage.haskell.org/package/bytestring-0.9.2.1/docs/s... ), so only the 64k chunks containing the parts we want will be kept.
There is a function 'copy' which will explicitly return a copy of only the character range that's used, so the original can be GCed ( https://hackage.haskell.org/package/bytestring-0.10.10.0/docs/Data-ByteString.html#v:copy https://hackage.haskell.org/package/bytestring-0.10.10.0/doc... )
- boygobbo 6y agoThanks for the clarification. BTW I agree with tome - your comment above would make a great blog post.
- chriswarbo 6y agoIt's now at http://chriswarbo.net/blog/2020-06-08-haskell_strings.html http://chriswarbo.net/blog/2020-06-08-haskell_strings.html