question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Leak sending huge amount of x-protobuf (byte[]) in a request to an http controller

See original GitHub issue

Expected behavior

When sending http requests to a Controller with huge data, no memory leak should happen.

Actual behavior

When sending a huge amount of data as application/x-protobuf to a @Controller a memory leak happens and a log trace appears.

Steps to reproduce

All of this has been tested in Linux (Ubuntu)

  • Clone this project https://github.com/dcalap/micronaut-netty-leak-problem build it and run it in Docker
  • Install Apache Benchmark to generate a big amount of requests
  • Generate a “big” file to be sent: dd if=/dev/zero of=post-500mb.data count=1024 bs=512000
  • Send it to our controller through Apache Benchmark: ab -T 'application/x-protobuf' -n 9999 -c 10 -p post-500mb.data http://[HOST_IP]:8080/dummy/issue

Minimal yet complete reproducer code (or URL to code)

https://github.com/dcalap/micronaut-netty-leak-problem

Netty version

4.1.38 (the one included in micronaut 1.2.2)

JVM version (e.g. java -version)

adoptopenjdk/openjdk11-openj9:jdk-11.0.1.13-alpine-slim

Log

10:20:11.351 [nioEventLoopGroup-1-8] 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:349) io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:187) io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:178) io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:139) io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator$MaxMessageHandle.allocate(DefaultMaxMessagesRecvByteBufAllocator.java:114) io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:147) io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:697) io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:632) io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:549) io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:511) io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918) io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base/java.lang.Thread.run(Thread.java:825)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
normanmaurercommented, Sep 27, 2019

@dcalap @marcosflobo the log is truncated (as noted at the end). Please use a higher “io.netty.leakDetection.targetRecords” setting and report back. Something like -Dio.netty.leakDetection.targetRecords=32.

1reaction
dcalapcommented, Sep 26, 2019

Because it looks like we read something in the buffer and then dispatched it to the pipeline.

Micronaut guys addressed us to netty. If you can check the referenced issue to see if maybe is netty stuff or you can talk to each other it would be great 😃 Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring RestController receive a huge size byteArray As ...
How can I read this large byte[] array in? Are there some better ways to do this? My current solution that's not working...
Read more >
Encoding | Protocol Buffers - Google Developers
They allow encoding unsigned 64-bit integers using anywhere between one and ten bytes, with small values using fewer bytes. Each byte in the ......
Read more >
Accepting Raw Request Body Content in ASP.NET Core API ...
NET Core Web API project and changed the default ValuesController to this ... Retrieves the raw body as a byte array from the...
Read more >
ReadableByteStreamController - Web APIs - MDN Web Docs
It allows control of the state and internal queue of a ReadableStream with an underlying byte source, and enables efficient zero-copy transfer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found