A Deep Dive into Binaries
summary
Covers concrete rules and numbers: binaries copy onto the process heap when ≤64 bytes and become process-heap binaries up to 64 bytes, larger data uses ref-counted sub-binaries that prevent parent GC until released. Shows parsers for PNG/JPEG/PDF built with binary pattern matching, demonstrates binary.copy to avoid GC retention for long-lived slices, explains delayed sub-binary optimization inside BEAM and how to enable bin_opt_info to see missed optimizations.
AI-written summary · about
chapters (18)
- 0:00Intro
- 0:58Table of Contents
- 1:31Properties
- 2:44Creating a binary
- 3:09What is an Elixir binary?
- 4:41Types - Defaults
- 5:30Options - Ordering
- 6:12Options - Unit and Size - Example
- 8:03Matching - Use Case
- 11:06Internal Representations (cont.)
- 12:58Process Heap Binaries
- 14:11Reference Counting
- 17:19Appending Binaries
- 20:24Sub-binary sadness
- 24:22Sub-binary solution!
- 24:47Binary Matching - The Sad Way
- 27:53Binary Matching - happy path
- 31:27Binary Optimization - Compiler Flag








