golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.64k stars 1.58k forks source link

Memory Leak Issue #1549

Closed satya-devloper closed 1 year ago

satya-devloper commented 1 year ago

Using Library : google.golang.org/protobuf version : 1.26.0 go version 1.19

In my code I am creating multiple websocket connection and sending multiple proto message On receive of each message on websocket connection, doing proto.Unmarshal

And When I enable profiling , I can see the profiling looks like.

Screenshot 2023-05-28 at 2 35 08 PM

Is there any memory leak while doing proto.unmarshal and proto.marshal ? As I can see the numbers on arrow used to get increased and never decreased when I stop sending message also. Please suggest some fix

puellanivis commented 1 year ago

These seem like perfectly normal memory allocation hotspots. The package shouldn’t be retaining any pointers to these objects… what are you doing with the messages yourself?

satya-devloper commented 1 year ago

Once I got the message from connection , I m unmarsahlling it to proto type and then send it to kafka write

So functionality is somewhat like this fun read() { reqprotomsgtype := &pb.msgType{} byteArrayMesssage := conn.read()

proto.Unmarshal(bytearrayMessage, reqprotomsgtype)

senditToKafka(reqprotomsgtype) }

func sendItToKafka(msg){ byte := proto.marsahl(msg.Data) kafka.write(byte, topic) }

chressie commented 1 year ago

I agree with @puellanivis assessment, that there shouldn't be a memory leak on the protobuf side of things. So, perhaps the memory is retained somewhere else in the program. I'm closing this as long as there's no reproducer available.