zeromq(jeromq)receive调用导致java gc循环

wmvff8tz  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(194)

我正在评估zeromq作为低延迟项目的候选者。但是我找不到一种方法来阻止gc循环,这是纯java实现recv调用造成的。有没有办法告诉zeromq使用相同的字节缓冲区进行同步读取?

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++;
        }
    }

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题