Hi Belisko,

The code snippets seems insufficient to diagnose any form of memory leak. 
For example, what happens to the s variable in createMessage? Is the 
dataTosend variable a buffered channel? What's consuming the other end of 
the channel and is it keeping up with the transmission rate? There's a lot 
of factors (most of which have little to nothing to do with protocol 
buffers) that can affect a lot of memory being held on the heap.

Memory leaks can be notoriously hard to diagnose. It might help to see how 
others tackled the problem: 
https://blog.detectify.com/2019/09/05/how-we-tracked-down-a-memory-leak-in-one-of-our-go-microservices/

JT

On Friday, May 29, 2020 at 11:52:46 AM UTC-7, Belisko Marek wrote:
>
> Hi,
>
> I'm using protobuf in golang programming language.Currently I'm hunting 
> for some memory issue and used pprof tool to check heap usage of my program.
> Proto message is created in function and returned then in main neverending 
> loop is sent to channel to sent data.
>
> I create heap snapshot using pprof tool and looks like even memory to 
> message is not referenced buffer of message size is still occupied (I used 
> message payload like ~10M to be more visible).
>
> code snippet:
> func createMessage([]byte buff) []byte {
>    m := &protocol.Message{
> Application: "1",
> Payload:       buff,
> }
>   s, err := proto.Marshal(m)
>   return m
> }
>
>
> func main() {
>    ....
>    for {
>      select {
>      case buff := receivedData:
>          p := createMessage(buff)
>          dataTosend <- p
>      }
>    }
> }
>
> Am I doing something wrong here? Program work fine but when using payload 
> like 100M (on embedded device) I'm getting after few attempts out of memory 
> issue.
>
> Thanks.
>
> BR,
>
> marek
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/0f829387-6200-4083-8845-23fc90a3e92b%40googlegroups.com.

Reply via email to