# OutOfMemoryError: Direct buffer memory

**URL:** <https://discuss.elastic.co/t/outofmemoryerror-direct-buffer-memory/16402>\
**Category:** Elasticsearch\
**Created:** [March 17, 2014, 9:39am UTC](https://discuss.elastic.co/t/outofmemoryerror-direct-buffer-memory/16402 "2014-03-17T09:39:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Guo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_guo/32/1725_2.png) [@Daniel\_Guo](https://discuss.elastic.co/u/Daniel_Guo)\
**Post date:** [March 17, 2014, 9:39am UTC](https://discuss.elastic.co/t/outofmemoryerror-direct-buffer-memory/16402/1 "2014-03-17T09:39:01Z")

</div>

I use elasticsearch as an index server. And I deploy a web project to  
create index and search result from my es server.

I got the following error from the logs of the web project:

[elasticsearch[Vengeance][transport\_client\_worker][T#12]{New I/O worker  
#6249}] WARN  
org.elasticsearch.netty.channel.socket.nio.AbstractNioSelector -  
Unexpected exception in the selector loop.  
java.lang.OutOfMemoryError: Direct buffer memory  
at java.nio.Bits.reserveMemory(Bits.java:632)  
at java.nio.DirectByteBuffer.(DirectByteBuffer.java:97)  
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)  
at  
org.elasticsearch.common.netty.channel.socket.nio.SocketReceiveBufferAllocator.newBuffer(SocketReceiveBufferAllocator.java:64)  
at  
org.elasticsearch.common.netty.channel.socket.nio.SocketReceiveBufferAllocator.get(SocketReceiveBufferAllocator.java:41)  
at  
org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:62)  
at  
org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)  
at  
org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)  
at  
org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)  
at  
org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)  
at  
org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)  
at  
org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:662)

ES\_HEAP\_SIZE=2048, and the server running elasticsearch has free memory of  
8GB.

Any ideas of the root causing the error? thanks verymuch!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2908b469-26ae-412c-bf1d-63d693aac543%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2908b469-26ae-412c-bf1d-63d693aac543%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 17, 2014, 12:33pm UTC](https://discuss.elastic.co/t/outofmemoryerror-direct-buffer-memory/16402/2 "2014-03-17T12:33:07Z")

</div>

Are you sending an enormous bulk indexing request? If so, try to send  
fewer docs at a time, eg 1,000

On 17 March 2014 10:39, Daniel Guo [daniel5hbs@gmail.com](mailto:daniel5hbs@gmail.com) wrote:

> I use elasticsearch as an index server. And I deploy a web project to  
> create index and search result from my es server.
> 
> I got the following error from the logs of the web project:
> 
> [elasticsearch[Vengeance][transport\_client\_worker][T#12]{New I/O worker  
> #6249}] WARN  
> org.elasticsearch.netty.channel.socket.nio.AbstractNioSelector -  
> Unexpected exception in the selector loop.  
> java.lang.OutOfMemoryError: Direct buffer memory  
> at java.nio.Bits.reserveMemory(Bits.java:632)  
> at java.nio.DirectByteBuffer.(DirectByteBuffer.java:97)  
> at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.SocketReceiveBufferAllocator.newBuffer(SocketReceiveBufferAllocator.java:64)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.SocketReceiveBufferAllocator.get(SocketReceiveBufferAllocator.java:41)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:62)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)  
> at  
> org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)  
> at  
> org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:662)
> 
> ES\_HEAP\_SIZE=2048, and the server running elasticsearch has free memory of  
> 8GB.
> 
> Any ideas of the root causing the error? thanks verymuch!
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/2908b469-26ae-412c-bf1d-63d693aac543%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2908b469-26ae-412c-bf1d-63d693aac543%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/2908b469-26ae-412c-bf1d-63d693aac543%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2908b469-26ae-412c-bf1d-63d693aac543%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKRuBe0iQyX5DET\_syLDSq8fRTNReVcw40hq\_PCi3bWKmg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKRuBe0iQyX5DET_syLDSq8fRTNReVcw40hq_PCi3bWKmg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Daniel\_Guo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_guo/32/1725_2.png) [@Daniel\_Guo](https://discuss.elastic.co/u/Daniel_Guo)\
**Post date:** [March 17, 2014, 3:00pm UTC](https://discuss.elastic.co/t/outofmemoryerror-direct-buffer-memory/16402/3 "2014-03-17T15:00:36Z")

</div>

Yes, my bulk size is 10,000. I'll try to make it smaller.  
Thanks a lot, Clinton!

On Monday, March 17, 2014 8:33:07 PM UTC+8, Clinton Gormley wrote:

> Are you sending an enormous bulk indexing request? If so, try to send  
> fewer docs at a time, eg 1,000
> 
> On 17 March 2014 10:39, Daniel Guo \<[danie...@gmail.com](mailto:danie...@gmail.com) \<javascript:\>\>wrote:
> 
> > I use elasticsearch as an index server. And I deploy a web project to  
> > create index and search result from my es server.
> > 
> > I got the following error from the logs of the web project:
> > 
> > [elasticsearch[Vengeance][transport\_client\_worker][T#12]{New I/O worker  
> > #6249}] WARN  
> > org.elasticsearch.netty.channel.socket.nio.AbstractNioSelector -  
> > Unexpected exception in the selector loop.  
> > java.lang.OutOfMemoryError: Direct buffer memory  
> > at java.nio.Bits.reserveMemory(Bits.java:632)  
> > at java.nio.DirectByteBuffer.(DirectByteBuffer.java:97)  
> > at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.SocketReceiveBufferAllocator.newBuffer(SocketReceiveBufferAllocator.java:64)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.SocketReceiveBufferAllocator.get(SocketReceiveBufferAllocator.java:41)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:62)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)  
> > at  
> > org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)  
> > at  
> > org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> > at java.lang.Thread.run(Thread.java:662)
> > 
> > ES\_HEAP\_SIZE=2048, and the server running elasticsearch has free memory  
> > of 8GB.
> > 
> > Any ideas of the root causing the error? thanks verymuch!
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/2908b469-26ae-412c-bf1d-63d693aac543%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2908b469-26ae-412c-bf1d-63d693aac543%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/2908b469-26ae-412c-bf1d-63d693aac543%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2908b469-26ae-412c-bf1d-63d693aac543%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e134b25f-0c2b-4611-82b7-45d69eaa417b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e134b25f-0c2b-4611-82b7-45d69eaa417b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:42am UTC](https://discuss.elastic.co/t/outofmemoryerror-direct-buffer-memory/16402/4 "2017-07-06T01:42:47Z")

</div>


