3

I am evaluating ZeroMQ as a candidate for a low latency project. But I could not find a way to stop GC cycles which are causing from pure java implementation recv calls. Is there any way to tell ZeroMQ to use same byte buffer for synchronous reads?

private static ZContext context;
public static void main(String[] args)
{
    try
    {
        context = new ZContext();
        ZFrame qFrame = new ZFrame(queryBuffer);

        // Socket to talk to clients
        ZMQ.Socket socket = context.createSocket(SocketType.REQ);
        socket.connect(ConnectionUtils.tcp(serverIp, serverPort));
        
        //socket.setHWM(1000);
        //socket.setReceiveBufferSize(2000);
        //socket.setLinger(1000);
        //socket.setRcvHWM(1000);
        int i = 0;
        while (!Thread.currentThread().isInterrupted())
        {
            qFrame.sendAndKeep(socket, 0);

            socket.recv(0);
            // ZFrame f= ZFrame.recvFrame(socket,0);
            // f.destroy();
            //ZMsg answer=ZMsg.recvMsg(socket,0);
            //answer.destroy();
            //socket.recvByteBuffer(answerBuf,0);
            // answerBuf.clear();

            i++;
        }
    }

}

enter image description here

ayengin
  • 1,606
  • 1
  • 22
  • 47
  • what does gc has to do with `zeromq` here? you allocated? you get GC calls – Eugene Nov 26 '20 at 20:04
  • I try different method signatures . Pass static byte arrays to recv methods. But it seems zeromq allocating new byte buffers during recv calls. I am trying to find a way to tell zeromq not to allocate new byte buffers. – ayengin Nov 27 '20 at 07:06
  • Basically i want to allocate a fixed buffer for recv calls. But socket api somehow creating new objects which eventually causing gc. – ayengin Nov 29 '20 at 17:25
  • I don't know much about zeromq, but you need to provide the example you are using ( exactly ) that gets that screenshot. – Eugene Nov 29 '20 at 17:54
  • @Eugene I do a simple request reply server/client and problem continue. I think this is the situation for very basic example. For example codes https://github.com/auengine/zeromq – ayengin Nov 30 '20 at 08:28

0 Answers0