Reduce memory consumption of packet serialization