I have an issue with protobuf marshalling consuming a lot of memory. Over the time it looks like a memory leak: process consumes a lot of heap and finally gets killed by OOM. The service is a networking cache for protobuf objects and the vast majority are read-requests.
A brief look into a heap profile points to protobuf marshalling as one of the main contributors.
Can someone explain why this memory is not reclaimed? In my mind, marshaling should not add anything to memory usage since the response buffers are sent. Does protobuf retains memory for future reuse?
Here is the relevant part of go tool pprof -pdf binary heap.txt