Bedrock - a scaleable, distributed key-value database with better-than-ACID guarantees

Slices are great for temporary work, but the memory bloat can be more permanent. The slice retains a reference to the underlying binary and there can be significant amounts of memory that are accidentally / quietly retained. For example, you read in a 10mb chunk from somewhere, and slice out one 10 byte value to keep. As long as there’s a reference to the 10 byte value, the whole 10mb sticks around, even if you’ve discarded all references to the 10mb chunk. You can sever this linkage with an explicit :binary.copy, though. :binary.referenced_byte_size can tell you more about this, too. There are a bunch of fun toys in:

3 Likes