pebbe / zmq4

A Go interface to ZeroMQ version 4
BSD 2-Clause "Simplified" License
1.17k stars 163 forks source link

Memory leak pub/sub #103

Closed Arhius closed 7 years ago

Arhius commented 7 years ago

Hello I have an issue with pub/sub model. I have one publisher that binds to ip:5556 and 4 workers(subs) that connects to ip:5556. Publisher After few hour of test work the usage of used memory increased. Can You please recommend me how can I solve such problem? Maybe used other zmq model My publisher code

zmqContext, _ := zmq.NewContext()
pub, _ := zmqContext.Socket(zmq.PUB)
defer pub.Close()
pub.Bind(fmt.Sprintf("tcp://%s:5556", *ip))
   ...

   ...
if *isSync {
    go func() {
        b.pub.Out() <- [][]byte{[]byte(*ip), []byte(fmt.Sprintf("%d|%s|%s", group.Id, link, gl))}
    }()
}

And SUB code for one of workers:

func GatherSyncData(ip string, cache *ccache.Cache) {
    sub, _ := zmq.NewSocket(zmq.SUB)
    defer sub.Close()
    sub.Connect(fmt.Sprintf("tcp://%s:5556", ip))
    sub.SetSubscribe(ip)
    for {
        message, err := sub.RecvMessage(0)
        if err != nil {
            log.Println(err)
            break
        }
        go SeveSyncUUID(message, cache)
    }
}
pebbe commented 7 years ago

This is not a proper issue.

For help with using ZeroMQ, please consult the mailing list that is listed on the ZeroMQ website.