Arrow JavaScript · memory
Keep columns as views over the buffers you already have.
Arrow’s memory model is built around contiguous buffers, chunked record batches, and logical vectors that can share those buffers. That makes slicing and transfer inexpensive when the operation does not require flattening.
The memory model
Share storage first; materialize only at a boundary.
Record batches own chunks of column data. Tables and vectors compose views over those chunks, so many reads can avoid copying until the application explicitly asks for a flattened or converted representation.
Buffers
Incoming ArrayBuffers hold contiguous bytes
Chunks
Each record batch contributes column slices
Views
Vectors and tables compose logical columns
Copies
Flattening and conversion create new storage
Detailed guide
Memory management details
The notes below explain buffer ownership, chunked columns, slicing, immutability, and the operations that cross the no-copy boundary.
Notes on Memory Management
Apache Arrow is a performance-optimized architecture, and the foundation of that performance is the approach to memory management. It can be useful to have an understanding of how.
How Arrow Stores Data
Arrow reads in arrow data as arraybuffer(s) and then creates chunks that are "sub array views" into that big array buffer, and lists of those chunks are then composed into "logical" arrays.
Chunks are created for each column in each RecordBatch.
The chunks can be "sliced and diced" by operations on Column, Table and DataFrame objects, but are never copied (as long as flattening is not requested) and are conceptually immutable. (There is a low-level Vector.set() method however given that it could modify data that is used by multiple objects its use should be reserved for cases where implications are fully understood).