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.

[BUG] OutOfMemoryError: Direct buffer memory when uploading large file

See original GitHub issue

Describe the bug When I’m trying to upload file much bigger than heap to blob storage size I’m getting OutOfMemoryError

Exception or Stack Trace

Operator called default onErrorDropped
java.lang.IllegalStateException: java.lang.OutOfMemoryError: Direct buffer memory
	at io.netty.channel.AbstractCoalescingBufferQueue.releaseAndCompleteAll(AbstractCoalescingBufferQueue.java:351)
	at io.netty.channel.AbstractCoalescingBufferQueue.releaseAndFailAll(AbstractCoalescingBufferQueue.java:207)
	at io.netty.handler.ssl.SslHandler.releaseAndFailAll(SslHandler.java:1814)
	at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1793)
	at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1757)
	at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:775)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:748)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:740)
	at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:726)
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.flush(CombinedChannelDuplexHandler.java:531)
	at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:125)
	at io.netty.channel.CombinedChannelDuplexHandler.flush(CombinedChannelDuplexHandler.java:356)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:748)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:740)
	at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:726)
	at reactor.netty.channel.MonoSendMany$SendManyInner.run(MonoSendMany.java:296)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.OutOfMemoryError: Direct buffer memory
	at java.base/java.nio.Bits.reserveMemory(Bits.java:175)
	at java.base/java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118)
	at java.base/java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317)
	at io.netty.buffer.PoolArena$DirectArena.allocateDirect(PoolArena.java:758)
	at io.netty.buffer.PoolArena$DirectArena.newChunk(PoolArena.java:734)
	at io.netty.buffer.PoolArena.allocateNormal(PoolArena.java:245)
	at io.netty.buffer.PoolArena.allocate(PoolArena.java:227)
	at io.netty.buffer.PoolArena.allocate(PoolArena.java:147)
	at io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:342)
	at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:187)
	at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:178)
	at io.netty.handler.ssl.SslHandler$SslEngineType$1.allocateWrapBuffer(SslHandler.java:215)
	at io.netty.handler.ssl.SslHandler.allocateOutNetBuf(SslHandler.java:2145)
	at io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:821)
	at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:792)
	at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:773)
	... 17 more

To Reproduce Steps to reproduce the behavior:

Code Snippet

azure.getBlobClient(blobName).uploadFromFile(absolutePath, overwrite)

Expected behavior Do not fail with error

Setup (please complete the following information):

  • OS: Windows, Linux, Mac OS X
  • IDE : IntelliJ
  • Version of the Library used: 12.6.1

Additional context I have bunch of another reports/questions because I have very special setup: I’m developing plugin for IDE, so my files are being loaded with another classloader (which is not even URLClassloader) and also it works inside IDE so potentially strange side-effects may occure.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:44 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
rickle-msftcommented, Jun 8, 2020

Makes sense to me! Thank you for giving it a test! I am going to close this issue since I believe it has been resolved. The fix is in master and will go out with our GA release this week or next.

0reactions
d-schmidtcommented, Jun 22, 2021

According to the reactor Queues class, this is the minimum:

    System.setProperty("reactor.bufferSize.x", "8"); // default 32
    System.setProperty("reactor.bufferSize.small", "16"); // default 256
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix java.lang.OufOfMemoryError: Direct Buffer Memory
lang.OutOfMemoryError: Direct buffer memory is increasing JVM default memory limit. By default, JVM allows 64MB for direct buffer memory, you can increase it ......
Read more >
Direct buffer memory when invoking Files.readAllBytes
When loading files into memory, java allocates a series of DirectByteBuffers using a different, non-heap pool called the direct memory pool.
Read more >
'OutOfMemoryError: Direct buffer memory' in DiskFileItem.get()
Thus this may result in 'OutOfMemoryError: Direct buffer memory' for large or multiple concurrent multipart uploads, ...
Read more >
Troubleshooting OutOfMemoryError: Direct buffer memory
As we said, the Direct Buffers are allocated to native memory space outside of the JVM's established heap/perm gens. If this memory space ......
Read more >
java.lang.OutOfMemoryError: Direct buffer memory issue
I am not uploading any files but post JSONS which are relatively small (Largest one is 515 Byes). However, due to the amount...
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