Memory leak in ZlibEncoder/Decoder?

Norman Maurer norman.maurer at googlemail.com
Mon Oct 17 14:05:54 EDT 2011


Would it be possible to upload the heap dump somewhere ?

Thanks,
Norman


2011/10/17 Evil Ipos <evil.ipos at gmail.com>:
> I have simple server, that waits for TCP connections on specified port. Send
> reply (around 500 bytes) and close connection. It is around 100 requests per
> minute. When i added ZlibEncoder/Decoder to pipline i get sometimes OOM.
> Without ZlibEncoder/Decoder all works ok. JVM has assigned 4GB of memory so
> i think enough for 100 clients.
>
> I used VisualVM to profile my application, and when looked at number of
> class instances i see that classes from netty.util.internal.jzlib.* are
> growing (when i perfrom GC nothing happen to them)
>
> I'm doing something wrong or Zlib Encoder/Decoder has memory leak?
>
> This is my PiplineFactory (MultiProtobufDecoder & MultiProtobufEncoder come
> from Netty 4)
>
> package update.listener;
>
> import ipm.codec.protobuf.MultiProtobufDecoder;
> import ipm.codec.protobuf.MultiProtobufEncoder;
> import ipm.core.Protocol;
>
> import org.jboss.netty.channel.ChannelHandler;
> import org.jboss.netty.channel.ChannelPipeline;
> import org.jboss.netty.channel.ChannelPipelineFactory;
> import org.jboss.netty.channel.Channels;
> import org.jboss.netty.handler.codec.compression.ZlibDecoder;
> import org.jboss.netty.handler.codec.compression.ZlibEncoder;
> import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
> import
> org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
>
> final class PipelineFactory implements ChannelPipelineFactory {
>        private final ChannelHandler frameEncoder;
>        private final ChannelHandler protobufEncoder;
>        private final ChannelHandler protobufDecoder;
>        private final ChannelHandler requestHandler;
>
>        public PipelineFactory(final ListenerService listenerService) {
>                frameEncoder = new ProtobufVarint32LengthFieldPrepender();
>                protobufEncoder = new MultiProtobufEncoder(Protocol.getResponses(),
>                                Protocol.HEADER_SIZE);
>                protobufDecoder = new MultiProtobufDecoder(Protocol.getRequests(),
>                                Protocol.HEADER_SIZE);
>                requestHandler = new RequestHandler(listenerService);
>        }
>
>        @Override
>        public ChannelPipeline getPipeline() throws Exception {
>                final ChannelPipeline pipeline = Channels.pipeline();
>
>                pipeline.addLast("zlibDecoder", new ZlibDecoder());
>                pipeline.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
>                pipeline.addLast("protobufDecoder", protobufDecoder);
>
>                pipeline.addLast("zlibEncoder", new ZlibEncoder());
>                pipeline.addLast("frameEncoder", frameEncoder);
>                pipeline.addLast("protobufEncoder", protobufEncoder);
>                pipeline.addLast("requestHandler", requestHandler);
>
>                return pipeline;
>        }
> }
>
> messageReceived() from RequestHandler looks:
>
>        @Override
>        public void messageReceived(final ChannelHandlerContext ctx,
>                        final MessageEvent e) throws Exception {
>                Object message = null;
>
>                if (e.getMessage() instanceof PackageRepositoryRequest)
>                        message = handlePackageRepositoryRequest(ctx,
>                                        (PackageRepositoryRequest) e.getMessage());
>                else if (e.getMessage() instanceof LastPackageRepositoryUpdateTimeRequest)
>                        message = handleLastPackageRepositoryUpdateTimeRequest(ctx,
>                                        (LastPackageRepositoryUpdateTimeRequest) e.getMessage());
>                else if (e.getMessage() instanceof PackageRequest)
>                        message = handlePackageRequest(ctx, (PackageRequest) e.getMessage());
>
>                if (message != null)
>                        ctx.getChannel().write(message)
>                                        .addListener(ChannelFutureListener.CLOSE);
>        }
>
> --
> View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Memory-leak-in-ZlibEncoder-Decoder-tp6901578p6901578.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>



More information about the netty-users mailing list