# OutOfMemory Error for Priority Queue for "Sync" search

**URL:** <https://discuss.elastic.co/t/outofmemory-error-for-priority-queue-for-sync-search/5280>\
**Category:** Elasticsearch\
**Created:** [August 30, 2011, 1:21pm UTC](https://discuss.elastic.co/t/outofmemory-error-for-priority-queue-for-sync-search/5280 "2011-08-30T13:21:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![komaln](https://avatars.discourse-cdn.com/v4/letter/k/8797f3/32.png) [@komaln](https://discuss.elastic.co/u/komaln)\
**Post date:** [August 30, 2011, 1:21pm UTC](https://discuss.elastic.co/t/outofmemory-error-for-priority-queue-for-sync-search/5280/1 "2011-08-30T13:21:30Z")

</div>

Hi all,

I am using elasticsearch to search through my logs. The data I am searching through is really large. I am using sync query using the function "query\_then\_fetch".  
But when I set large "size" (more than 10,000) using "builder.setSize" I see following OutOfMemory error:  
  
Exception in thread "elasticsearch[search]-pool-3-thread-1" java.lang.OutOfMemoryError: Requested array size e  
at org.apache.lucene.util.PriorityQueue.initialize(PriorityQueue.java:108)  
at org.apache.lucene.search.ShardFieldDocSortedHitQueue.(ShardFieldDocSortedHitQueue.java:48)  
at org.elasticsearch.search.controller.SearchPhaseController.sortDocs(SearchPhaseController.java:189)

Is there any way to know how much "size" (builder.setSize) can be set before we get this OutOfMemory error.

Thanks and Regards,  
Komal.

---

<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, 3:55am UTC](https://discuss.elastic.co/t/outofmemory-error-for-priority-queue-for-sync-search/5280/2 "2017-07-06T03:55:35Z")

</div>


