By default, gRPC uses
Protobuf parser for decoding data. You can definitely implement your own marshaller and do it yourself (see the
Json serialization example). However, that's mostly for choosing to use a different format of serialization and probably won't make the problem of creating temp objects better. As most of them happen in
deframing messages, that's the part you do not have control for. There had been
work for making some improvement, but I believe most of them weren't be having significant impact on garbage collection. That's said, there probably isn't much can be done in terms of improving GC pressure.
On the other hand, the existing Protobuf marshaller does have something can be improved, which is
making an extra copy of received bytes before handing them over to Protobuf parser (but it does
reuse the byte array to avoid excessive amount of allocation and GC). There had been
attempts to eliminate this copy, but it turned out requiring changes in Protobuf or JDK to make the gain larger than the extra cost. There's continued effort on that path. That's being said, if you are going to implement your own marshaller, you may be able to eliminate this copy.