GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Memory leak when using SslHandler · Issue #13698 · netty/netty Closed DescriptionExpected behaviorNo memory leak. Actual behaviorWhen a connection is open, we send data and the ram usage increase depending on the size of the data. The java heap stay in a correct range (500 - 1000 Mb) but the process ram is increasing for each request (approximately by the size of the send payload). The problem source is probably the off-heap allocation but even with the option When disabling the Steps to reproduce
Minimal yet complete reproducer code (or URL to code)
dd if=/dev/urandom of=/tmp/random1G.bin bs=1G count=1 status=progress
package org.example import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.ByteBuf; import io.netty.channel.*; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.logging.LogLevel; import io.netty.handler.logging.LoggingHandler; import io.netty.handler.ssl.ClientAuth; import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContextBuilder; import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.IOException; public class Main { static final int PORT = Integer.parseInt(System.getProperty("port", "2222")); public static void main(String[] args) throws Exception { SelfSignedCertificate selfSignedCertificate = new SelfSignedCertificate("test"); SslContext sslCtx = SslContextBuilder .forServer(selfSignedCertificate.certificate(), selfSignedCertificate.privateKey()) .clientAuth(ClientAuth.OPTIONAL) .protocols(new String[] {"TLSv1.3"}) .build(); EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 100) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) { ch.pipeline() .addLast(sslCtx.newHandler(ch.alloc())) .addLast(new ChannelInboundHandlerAdapter() { @Override public void channelActive(final ChannelHandlerContext ctx) { try { byte[] datas = new FileInputStream("/tmp/random1G.bin").readAllBytes(); ByteBuf buffer = ctx.alloc().buffer(datas.length); buffer.writeBytes(datas); ctx.writeAndFlush(buffer).addListener(f -> ctx.close()); } catch (IOException e) { System.out.println("closing " + e.getMessage()); ctx.close(); } } }) .addLast(new ChannelDuplexHandler() { @Override public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) { ctx.close(); } }); } }); // Bind and start to accept incoming connections. ChannelFuture f = b.bind(PORT).sync(); // Wait until the server socket is closed. // In this example, this does not happen, but you can do that to gracefully // shut down your server. f.channel().closeFuture().sync(); } finally { workerGroup.shutdownGracefully(); bossGroup.shutdownGracefully(); } } } Netty version6.1.101.Final JVM version (e.g.
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |