ZeroMQ(JeroMQ) receive calls cause java gc cycles

199 Views Asked by At

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

0

There are 0 best solutions below