FlatBuffers: Memory-Efficient Serialization
Article Summary
Wouter van Oortmerssen from Google's Fun Propulsion Labs just open-sourced FlatBuffers, a serialization library that reads data without unpacking or allocating extra memory. Game developers struggling with performance overhead, this one's for you.
Google released FlatBuffers as an open-source C++ serialization library specifically designed for game developers. The library stores data in cross-platform buffers that can be accessed in-place without parsing, offering a more efficient alternative to Protocol Buffers or JSON for game data storage.
Key Takeaways
- Reads serialized data without unpacking or allocating additional memory
- Cross-platform C++ with no library dependencies outside STL
- Schema compiler generates code for C++ and Java
- Supports full forwards and backwards compatibility through schemas
- Can parse JSON into type-safe binaries
FlatBuffers eliminates parsing overhead by letting you access serialized data directly in-place, making it faster and more memory-efficient than Protocol Buffers or JSON for game development.
About This Article
Game developers needed a way to store and transmit data efficiently across Android, Linux, OSX, and Windows while keeping compatibility as formats changed over time.
Wouter van Oortmerssen's team at Fun Propulsion Labs created FlatBuffers using C++ with only STL dependencies. The schema compiler generates code for both C++ and Java.
FlatBuffers doesn't require unpacking or allocating extra memory when accessing data. This gives game developers lower overhead compared to Protocol Buffers or JSON for storing game data.