如何释放com.sun.net.ssl.internal.ssl.EngineOutputRecord使用的内存

时间:2012-11-30 08:17:52

标签: java sockets netty ssl

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

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

我的代码:

我的管道:

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

启动Netty:

    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));

0 个答案:

没有答案