# What does "Indices Lucene memory" mean? Using a large amount of heap space

**URL:** https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615
**Category:** Elasticsearch
**Created:** [February 24, 2016, 4:46pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615 "2016-02-24T16:46:58Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Melanie\_Zamora](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Melanie\_Zamora](https://discuss.elastic.co/u/Melanie_Zamora)
#### Post date: [February 24, 2016, 4:46pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/1 "2016-02-24T16:46:58Z")

</div>

Hi,

I'm running ES 1.7. 2 node cluster on Centos 7.  
Heap Size: 30GB out of 96GB total RAM.  
533 total shards  
155 indices  
1.7TB total index size  
Fielddata size is set to 40% of heap, so 12GB

Issue: Very long old JVM GCs. When JVM heap usage goes above 90%, GC takes 30seconds +.  
The only thing I've been able to do right now to remedy it is to run a clear cache. This is not a sustainable long run solution. The other thing I noticed is that total physical memory usage on the server never goes above 30-35%, which is basically heap usage.  
-- I see Indices Lucene Memory using 12GB of heap space. What makes up this 12GB?  
-- Why don't I see Lucene using any "off heap" memory?

 ![](https://us1.discourse-cdn.com/elastic/original/2X/3/3c9ad70c630f25359b95cb0c40c59bfe9b48db98.JPG)

---

<div class="post-metadata">

### Author: ![Melanie\_Zamora](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Melanie\_Zamora](https://discuss.elastic.co/u/Melanie_Zamora)
#### Post date: [February 24, 2016, 4:59pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/2 "2016-02-24T16:59:50Z")

</div>

Does Indices Lucene Memory translate to segments?  
If so, why are segments so large?

```
        "segments": {
           "count": 5175,
           "memory": "12.6gb",
           "memory_in_bytes": 13579396246,
           "index_writer_memory": "12.6mb",
           "index_writer_memory_in_bytes": 13228468,
           "index_writer_max_memory": "3.1gb",
           "index_writer_max_memory_in_bytes": 3394999889,
           "version_map_memory": "2.5mb",
           "version_map_memory_in_bytes": 2725444,
           "fixed_bit_set": "0b",
           "fixed_bit_set_memory_in_bytes": 0
        },
```

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [February 25, 2016, 5:46am UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/3 "2016-02-25T05:46:44Z")

</div>

You should reduce your shard count! This will help, ultimately that is the best solution.

---

<div class="post-metadata">

### Author: ![Melanie\_Zamora](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Melanie\_Zamora](https://discuss.elastic.co/u/Melanie_Zamora)
#### Post date: [February 25, 2016, 3:41pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/4 "2016-02-25T15:41:45Z")

</div>

> [@Melanie\_Zamora](#):
>
> 533 total shards155 indices

Thanks for the reply Mark. Whats the best way to do this? I've got a little over 155 indices and they all have 2 -3 shards each. I've set the replica to 0 for now for all of them to help reduce # of shards, but whats the best long term solution? Do I just need to scale out to more servers?  
And do you think that the # of shards is the reason why I get long GC times?

---

<div class="post-metadata">

### Author: ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)
#### Post date: [February 25, 2016, 3:55pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/5 "2016-02-25T15:55:21Z")

</div>

> [@Melanie\_Zamora](#):
>
> Whats the best way to do this?

Give each new index fewer shards. With two nodes you should probably give each new index a single replica and one shard. You can't easily re-shard your existing indexes but I'd do so for new ones.

---

<div class="post-metadata">

### Author: ![Melanie\_Zamora](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Melanie\_Zamora](https://discuss.elastic.co/u/Melanie_Zamora)
#### Post date: [February 25, 2016, 4:00pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/6 "2016-02-25T16:00:50Z")

</div>

Thanks. I've also been closing indices that are older than x number of days. So would that help to reduce the memory pressure? Also, would running an optimize on the open indices help use less heap memory as well?  
These are infrastructure logs so there is a new index per day.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [February 25, 2016, 6:37pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/7 "2016-02-25T18:37:10Z")

</div>

Move to weekly indices, or reduce the shard count in the template you are using as well.

---

<div class="post-metadata">

### Author: ![thn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thn/32/8061_2.png) [@thn](https://discuss.elastic.co/u/thn)
#### Post date: [February 25, 2016, 6:40pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/8 "2016-02-25T18:40:22Z")

</div>

Each shard is equivalent to one Lucene index and in theory, it can hold around 2 billions. If the input rate is a few millions a day, I don't think you'll need more than 2 shards per index. Hope this will help you reducing the number of shards and maybe the number of indices by indexing data into a weekly index, not a daily index.

Also, if you have a spare machine with less memory (let's say 8 to 16GB RAM) I suggest to use this machine as a Master Node to relieve the burden on the master/data node combination and you can put Kibana on this machine too. If you have another spare machine, I suggest to use it as a Client Node to relieve the burden on the Master Node because it looks like you have a lot of indices in this two-node cluster.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [February 25, 2016, 7:19pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/9 "2016-02-25T19:19:20Z")

</div>

Actually you are better off having all 3 data+master when you are this size.

---

<div class="post-metadata">

### Author: ![thn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thn/32/8061_2.png) [@thn](https://discuss.elastic.co/u/thn)
#### Post date: [February 26, 2016, 11:21am UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/10 "2016-02-26T11:21:55Z")

</div>

I agree with you 100% @warkolm. I don't know about Melanie's case but I have a few cases where the customers can't afford to have 3 machines to start with.

---

<div class="post-metadata">

### Author: ![Melanie\_Zamora](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Melanie\_Zamora](https://discuss.elastic.co/u/Melanie_Zamora)
#### Post date: [February 26, 2016, 3:37pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/11 "2016-02-26T15:37:25Z")

</div>

Thanks for the reply guys.  
I can likely get a 3rd server but its kinda hard to justify a 3rd server when these 2 boxes are pretty under utilized when it come to CPU and also when it comes to overall RAM usage. Besides java using all the heap allocated (ES is allocated 30GB heap. Total available RAM on the box is 96GB). I read that Lucene uses off-heap RAM and so having lots available as file cache for Lucene will greatly improve full text search. However, from what I can see, my overall RAM usage never goes much above what I've allocated to ES. I don't see Lucene using any off heap memory at all for full text search. Do you gusy know more about this and how to get Lucene to use more off heap memory?

 ![](https://us1.discourse-cdn.com/elastic/original/2X/c/cb94ffb5d8c985bd97c884e1cc80ff261baf416f.JPG)

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [February 26, 2016, 6:44pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/12 "2016-02-26T18:44:08Z")

</div>

Using doc values will reduce your overall heap usage.

---

<div class="post-metadata">

### Author: ![Melanie\_Zamora](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Melanie\_Zamora](https://discuss.elastic.co/u/Melanie_Zamora)
#### Post date: [February 29, 2016, 6:06pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/13 "2016-02-29T18:06:03Z")

</div>

Thanks we've converted our non-analyzed string values to doc values

---

<div class="post-metadata">

### Author: ![Melanie\_Zamora](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Melanie\_Zamora](https://discuss.elastic.co/u/Melanie_Zamora)
#### Post date: [February 21, 2017, 5:51pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/14 "2017-02-21T17:51:50Z")

</div>

I still don't understand this and hoping someone can help me understand it. I read that Lucene uses off-heap RAM and so having lots available as file cache for Lucene will greatly improve full text search.  
I have a 96GB RAM machine. I've allocated 32GB to elasticsearch. The rest should theoretically be used by Lucene. However, my overall RAM usage never goes much above 32GB. I don't see Lucene using any off heap memory at all for full text search. Does anyone know why and how to get Lucene to use more off heap memory?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [February 21, 2017, 8:23pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/15 "2017-02-21T20:23:19Z")

</div>

That's handled by the OS caching files it uses, What OS are you on.

---

<div class="post-metadata">

### Author: ![Melanie\_Zamora](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Melanie\_Zamora](https://discuss.elastic.co/u/Melanie_Zamora)
#### Post date: [February 21, 2017, 8:37pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/16 "2017-02-21T20:37:22Z")

</div>

> [@warkolm](#):
>
> hat's handled by the OS caching files it us

I'm running on CentOS 7.

---

<div class="post-metadata">

### Author: ![Melanie\_Zamora](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Melanie\_Zamora](https://discuss.elastic.co/u/Melanie_Zamora)
#### Post date: [February 21, 2017, 8:39pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/17 "2017-02-21T20:39:29Z")

</div>

Is there a setting I need to tune to allow Lucene to use the remaining RAM?

---

<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 5, 2017, 10:03pm UTC](https://discuss.elastic.co/t/what-does-indices-lucene-memory-mean-using-a-large-amount-of-heap-space/42615/18 "2017-07-05T22:03:01Z")

</div>


