Array of structs
An array of structs is a collection of records in which each array element stores multiple fields belonging to one item.
High Performance Unity Game Development
An array whose elements are struct values stored together in the array's contiguous memory block.
- How it is used
- Uses grouped struct data when fields are always accessed together and no other logic needs them separately.
- How deep it goes
- Explains contiguous array storage and contrasts it with class-reference arrays, but does not provide performance measurements.
- Examples
- Uses coin pickup UI animations with current and target positions and velocity.
- What you can do after
- Evaluate whether related fields belong together in an array of structs or separate arrays.
Read how High Performance Unity Game Development explains array of structs →
Grokking GPU Programming
An array of structures stores records as an array in which each element contains multiple fields belonging to one record.
- How it is used
- Guides GPU data-layout choices by showing when interleaved records produce strided memory accesses.
- How deep it goes
- Explains record layout, thread strides, and coalescing, then compares SoA performance for selected workloads.
- Examples
- Uses particle position and velocity records to contrast AoS and SoA layouts and show particle updates.
- What you can do after
- Evaluate whether AoS or SoA better suits a kernel’s field-access pattern.
Read how Grokking GPU Programming explains array of structs →
Also covered in
What to know first
- cache lineA cache line is a fixed-size block of contiguous memory that a cache transfers or manages as a unit.
- data-oriented programmingData-oriented programming is an approach to structuring software around data representations and the operations, access patterns, and transformations applied to them.
- tensorA tensor is a multidimensional numerical array whose values are arranged along indexed dimensions and can be manipulated through mathematical computation.
Related concepts
- struct of arrayscontrasts with · A struct of arrays is a data layout that stores each field of multiple records in a separate array, with corresponding positions belonging to the same record.
- array of classescontrasts with · An array whose elements are references to class instances rather than the instances' inline data.
- contiguous memory layoutproduces · A contiguous memory layout stores adjacent data elements at adjacent memory addresses without gaps between them.
- vectorizationcontrasts with · Vectorization is the transformation of data or computations into vector form so they can be processed collectively by vector-oriented operations.
Questions about array of structs
What is array of structs?
An array of structs is a collection of records in which each array element stores multiple fields belonging to one item.
Which Manning books explain array of structs?
High Performance Unity Game Development and Grokking GPU Programming.
What should I know before learning array of structs?
Manning books that teach array of structs usually introduce cache line, data-oriented programming and tensor first.
What is the difference between array of structs and struct of arrays?
An array of structs is a collection of records in which each array element stores multiple fields belonging to one item. A struct of arrays is a data layout that stores each field of multiple records in a separate array, with corresponding positions belonging to the same record.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

