# java.lang.OutOfMemoryError: Java heap space

**URL:** <https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space/299620>\
**Category:** Elasticsearch\
**Tags:** elastic-agent\
**Created:** [March 14, 2022, 1:07pm UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space/299620 "2022-03-14T13:07:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_El\_bendary](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmed_el_bendary/32/77134_2.png) [@Ahmed\_El\_bendary](https://discuss.elastic.co/u/Ahmed_El_bendary)\
**Post date:** [March 14, 2022, 1:07pm UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space/299620/1 "2022-03-14T13:07:36Z")

</div>

when using prefix query with large text give exception then service will stop.

```auto
{
  "track_total_hits": true,
  "from": 0,
  "query": {
    "bool": {
      "minimum_should_match": 1,
      "must": [
        {
          "bool": {
            "must": [
              {
                "prefix": {
                  "form.reason": {
                    "value": "with large text .....",
                    "case_insensitive": true
                  }
                }
              }
            ]
          }
        }
      ],
      "should": [
        {
          "nested": {
            "path": "task",
            "query": {
              "term": {
                "form.userId": {
                  "value": 12
                }
              }
            }
          }
        }
      ]
    }
  },
  "size": 10,
  "sort": [
    {
      "createdDate": {
        "order": "desc"
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![DineshNaik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dineshnaik/32/89308_2.png) [@DineshNaik](https://discuss.elastic.co/u/DineshNaik)\
**Post date:** [March 14, 2022, 2:55pm UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space/299620/2 "2022-03-14T14:55:32Z")

</div>

you need to explain a bit more about your question.  
What is the exception?  
Check the logs to see full stack trace and share that here.

---

<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:** [April 11, 2022, 2:56pm UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space/299620/3 "2022-04-11T14:56:24Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
