Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Poller on Router to receive message lead to memory leak #282

Open
joeedt opened this issue Aug 28, 2020 · 0 comments
Open

use Poller on Router to receive message lead to memory leak #282

joeedt opened this issue Aug 28, 2020 · 0 comments

Comments

@joeedt
Copy link

joeedt commented Aug 28, 2020

when i use Dealer send message and Router recv message through Router-Dealer broker, the memory used by Router grow fastly, even though Dealer stop send message, the memory will not be freeed.

broker:

        proxy := goczmq.NewProxy()
	if err := proxy.SetFrontend(goczmq.Router, "tcp://127.0.0.1:4444"); err != nil {
		panic(err)
	}

	if err := proxy.SetBackend(goczmq.Dealer, "tcp://127.0.0.1:4445"); err != nil {
		panic(err)
	}

delear:

	sock, err := goczmq.NewDealer("tcp://127.0.0.1:44444")
	if err != nil {
		panic(err)
	}
	defer sock.Destroy()

	for {
		data := make([]byte, 10)
		sock.SendFrame(data, goczmq.FlagNone)
	}

router:

	sock := goczmq.NewSock(goczmq.Router)
	if err := sock.Attach("tcp://127.0.0.1:44445", false); err != nil {
		panic(err)
	}
	defer sock.Destroy()

	for {
		poller, err := goczmq.NewPoller(sock)
		if err != nil {
			panic(err)
		}
		defer poller.Destroy()

		if hitsock, err := poller.Wait(3000); err != nil {
			panic(err)
		} else if hitsock == nil {
			fmt.Println("wait timeout")
			continue
		} else {
			msg, err := hitsock.RecvMessage()
			fmt.Println(err, msg)
		}
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant