2

我有一个 netty 应用程序提供由 TLS 加密的 keep-alive 套接字连接。当socket连接数增加到100000或更多时,使用的jvm内存超过2.5G。

根据mat的内存报告,EngineOutputRecord(如图)使用了大部分内存。据我所知,这是TLS握手的信息,握手后无用。我想清除字节,但找不到任何方法,这里有什么建议吗? 垫子报告

我的代码:

我的管道:

 @Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();

    SSLEngine engine = SecurePushSslContextFactory.getServerContext()
            .createSSLEngine();
    engine.setUseClientMode(false);
    SslHandler sslHandler = new SslHandler(engine);

    pipeline.addLast("ssl", sslHandler);
    pipeline.addLast("framer", frame);
    pipeline.addLast("decoder", myDecoder);
    pipeline.addLast("handler", myHandler);

    return pipeline;
}

启动网络:

    ChannelFactory channelFactory = new NioServerSocketChannelFactory(
            Executors.newFixedThreadPool(1), // BOSS EXECUTOR
            Executors.newCachedThreadPool() // WORKER EXECUTOR
    );
    ServerBootstrap bootstrap = new ServerBootstrap(channelFactory);
    bootstrap.setPipelineFactory(new SecurePushServerPipelineFactory());
    bootstrap.bind(new InetSocketAddress(port));
4

0 回答 0