Flatbuffer memory layout

Rajan Chari
Apr 8, 2021

--

A small flatbuffer table

A small flatbuffer table
A small flatbuffer table

Its length is 20 bytes when serialized. (0– 19 in this example)

The first four bytes are the offset to the root. The root in this example is 12 bytes into the buffer.

The object at the root starts with the offset to the vtable describing the object. It’s 6 in this example. vtable starts at (root — 6) .

vtable consists of a) size of vtable, b) one or more field descriptors (id, offset from beginning of table). In this example, size is 6, id is 8 and offset from beginning of the table is 7.

root is beginning of the table at address 12. 12 + 7 = 19 is the location of the field.

The field contains the value 255.

--

--

Rajan Chari
Rajan Chari

Written by Rajan Chari

Currently working on reinforcement learning, high performance computing and robotics. In a previous life, high frequency finance, trading etc.

No responses yet