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?
Description:
When using the send method of the HttpClientConnector class, a memory leak is detected in the ByteBuf.
Here is my code:
I close the input and output stream in finally segment,but ByteBuf LEAK occurs.
The leak error is:
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?