Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using the send method of the HttpClientConnector class, a memory leak is detected in the ByteBuf. #460

Open
oyz1314 opened this issue May 5, 2023 · 3 comments

Comments

@oyz1314
Copy link

oyz1314 commented May 5, 2023

Description:
When using the send method of the HttpClientConnector class, a memory leak is detected in the ByteBuf.

Here is my code:

HttpResponseFuture responseFuture = httpClientConnector.send(request);
                              ... some bussiness code ...
httpMessage.getFullHttpCarbonMessage().addListener(new FullHttpMessageListener() {
                        @Override
                        public void onComplete(HttpCarbonMessage httpCarbonMessage) {
                            InputStream inputStream = null;
                            OutputStream outputStream = null;
                            try {
                                HttpMessageDataStreamer dataStreamer = new HttpMessageDataStreamer(httpCarbonMessage);
                                inputStream = dataStreamer.getInputStream();
                                outputStream = dataStreamer.getOutputStream();
                                byte[] content = IOUtils.toByteArray(inputStream);
                                ... some business code...
                          finally {
                                try {
                                    if (outputStream != null) {
                                        outputStream.close();
                                    }
                                    if (inputStream != null) {

                                        inputStream.close();
                                    }

I close the input and output stream in finally segment,but ByteBuf LEAK occurs.
The leak error is:

2023-04-27 01:25:17.158 1 [nioEventLoopGroup-29-4] ERROR io.netty.util.ResourceLeakDetector - LEAK: ByteBuf.release() was not called before it's garbage-collected. See https://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records: 
Created at:
 io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:403)
 io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:188)
 io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:179)
 io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:140)
 io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator$MaxMessageHandle.allocate(DefaultMaxMessagesRecvByteBufAllocator.java:120)
 io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:150)
 io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
 io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
 io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
 io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
 io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
 io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
 java.lang.Thread.run(Thread.java:748)

No wso2 related class is found.
So, i add code to calculate the direct buffer,when one response is coming, direct buffer increase 4096KB, every time is same。
Anyone can help me?

@yuqiu11
Copy link

yuqiu11 commented May 5, 2023

I also have this problem. Have you solved it?

@oyz1314
Copy link
Author

oyz1314 commented May 5, 2023

I also have this problem. Have you solved it?

Not yet.

@oyz1314
Copy link
Author

oyz1314 commented May 9, 2023

No one answer this question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants