# Minimize garbage collection

**URL:** <https://discuss.elastic.co/t/minimize-garbage-collection/153718>\
**Category:** Elasticsearch\
**Created:** [October 24, 2018, 5:43am UTC](https://discuss.elastic.co/t/minimize-garbage-collection/153718 "2018-10-24T05:43:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![surajdalvi](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@surajdalvi](https://discuss.elastic.co/u/surajdalvi)\
**Post date:** [October 24, 2018, 5:43am UTC](https://discuss.elastic.co/t/minimize-garbage-collection/153718/1 "2018-10-24T05:43:59Z")

</div>

Hi,

How to Minimize garbage collection memory in elastic cluster?

---

<div class="post-metadata">

**Author:** ![gbrown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gbrown/32/34482_2.png) [@gbrown](https://discuss.elastic.co/u/gbrown)\
**Post date:** [October 26, 2018, 2:56pm UTC](https://discuss.elastic.co/t/minimize-garbage-collection/153718/2 "2018-10-26T14:56:34Z")

</div>

Hi Suraj!

The most important thing is to make sure your heap size is set correctly - we have some [guidance on heap sizing in our documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html). There's also [this blog post](https://www.elastic.co/blog/a-heap-of-trouble) which goes into more depth on _why_ those recommendations improve memory usage and garbage collection.

That blog post also contains some usage recommendations, particularly around sharding, aggregations, and bulk indexing, to keep memory usage and garbage collection under control. The post is a couple years old now, but it is still very relevant.

---

<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:** [November 23, 2018, 2:56pm UTC](https://discuss.elastic.co/t/minimize-garbage-collection/153718/3 "2018-11-23T14:56:35Z")

</div>

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