# TopHitsAggregator objects are not Garbage Collected

**URL:** <https://discuss.elastic.co/t/tophitsaggregator-objects-are-not-garbage-collected/246487>\
**Category:** Elasticsearch\
**Created:** [August 26, 2020, 4:23pm UTC](https://discuss.elastic.co/t/tophitsaggregator-objects-are-not-garbage-collected/246487 "2020-08-26T16:23:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![parasharsh](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@parasharsh](https://discuss.elastic.co/u/parasharsh)\
**Post date:** [August 26, 2020, 4:23pm UTC](https://discuss.elastic.co/t/tophitsaggregator-objects-are-not-garbage-collected/246487/1 "2020-08-26T16:23:46Z")

</div>

Hi,Recently we saw the OOM on our ES instance. On Checking the Heap Dump in VisulaVM we observed large number of instances of org.apache.lucene.search.ScoreDoc in the HEAP - 41,984,154

The dominators by Retained size (Objects remaining in HEAP after GC) shows large percentage of heap being consumed by org.elasticsearch.search.aggregations.metrics.TopHitsAggregator.  
Any pointers what can be the root cause of these Objects not being Garbage Collected? We are using RestHighLevelClient to query ES. We never close the client as we use the same client for continuous indexing as well.

---

<div class="post-metadata">

**Author:** ![parasharsh](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@parasharsh](https://discuss.elastic.co/u/parasharsh)\
**Post date:** [September 1, 2020, 12:57pm UTC](https://discuss.elastic.co/t/tophitsaggregator-objects-are-not-garbage-collected/246487/2 "2020-09-01T12:57:02Z")

</div>

Any Hints Please.

---

<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:** [September 29, 2020, 12:57pm UTC](https://discuss.elastic.co/t/tophitsaggregator-objects-are-not-garbage-collected/246487/3 "2020-09-29T12:57:03Z")

</div>

Closed on September 29, 2020, 12:57pm UTC

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