There are three classifications of memory objects:
- Tiny: An object that is less than 16 bytes in size
- Small: An object that is greater than 16 bytes and less than or equal to 32 kB
- Large: An object that is larger than 32 kB in size
A tiny object in memory in Go performs the following process for memory allocation:
- If P's mcache has room, use that space.
- Take the existing sub object in the mcache and round it to 8, 4, or 2 bytes.
- Place the object in memory if it fits in the allocated space.
A small object in memory in Go follows a specific pattern for memory allocation:
- The object's size gets rounded up and classified into one of the small size classes that are generated in https://golang.org/src/runtime/mksizeclasses.go ...