Display warning about copy for lazy ByteString more prominent
- Dominant language
- Haskell
- Stars
- 301
- Forks
- 144
- Avg merge
- 7d 22h
- Merged PRs (30d)
- 1
Description
I had a huge memory-leak in my application because when reading the documentation for `BSL.ByteString` suggests that `copy` should allow the "parent" to be released for GC. I thought this was a bit suspicious, but went with it anyways and it turned out quite bad... So I checked the source:
```haskell
-- | /O(n)/ Make a copy of the 'ByteString' with its own storage.
-- This is mainly useful to allow the rest of the data pointed
-- to by the 'ByteString' to be garbage collected, for example
-- if a large string has been read in, and only a small part of it
-- is needed in the rest of the program.
copy :: ByteString -> ByteString
copy cs = foldrChunks (Chunk . S.copy) Empty cs
--TODO, we could coalese small blocks here
--FIXME: probably not strict enough, if we're doing this to avoid retaining
-- the parent blocks then we'd better copy strictly.
```
Important part here is the *FIXME* which does not show up in the docs but is critical in my opinion. Can we move this there?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.