# Very small ES instance consuming too much memory

**URL:** <https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926>\
**Category:** Elasticsearch\
**Created:** [July 22, 2011, 8:31am UTC](https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926 "2011-07-22T08:31:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rubish\_Gupta](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Rubish\_Gupta](https://discuss.elastic.co/u/Rubish_Gupta)\
**Post date:** [July 22, 2011, 8:31am UTC](https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926/1 "2011-07-22T08:31:49Z")

</div>

Hi,

I have a small application which is growing slowly. I only index user and  
posts data in ES for now. I haven't configured shrads/index, so probably it  
is using default of 5 shards/index. I have ~6k users and \<1k posts till  
now.

The server is a 512MB server, only running ES. Right now htop on server  
machine shows ES is consuming 1531MB of virtual memory. I do not have much  
experience in JAVA, so am not familiar with tools to monitor JVM and such,  
so pardon me if info I provide is insufficient. Here is the output of  
running free -m on the machine.

deploy@elastic1:~$ free -m  
total used free shared buffers cached  
Mem: 496 488 8 0 5 23  
-/+ buffers/cache: 459 36  
Swap: 1023 568 455

I guess it should not be using such a huge amount of memory. First thing I  
will do is decrease the number of shards from 5 to 1. Next I am planning to  
migrate to ES 0.17.1(currently I am using 0.15.2), but it might take some  
time before I migrate. What do you guys suggest I can do in meanwhile to  
control this memory overflow?

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [July 22, 2011, 2:31pm UTC](https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926/2 "2011-07-22T14:31:24Z")

</div>

did you specify the maximum and minimum memory?

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

it should be

ES\_MIN\_MEM=256m  
ES\_MAX\_MEM=256m

as approx the half of the available memory should be free for the OS  
itself (to allow caching on OS-side)

And then only if ES requires more memory it'll throw OutOfMemoryError.  
then you should either decrease memory usage or increase RAM 😉

On 22 Jul., 10:31, rubish gupta [rubish.gu...@almaconnect.com](mailto:rubish.gu...@almaconnect.com) wrote:

> Hi,
> 
> I have a small application which is growing slowly. I only index user and  
> posts data in ES for now. I haven't configured shrads/index, so probably it  
> is using default of 5 shards/index. I have ~6k users and \<1k posts till  
> now.
> 
> The server is a 512MB server, only running ES. Right now htop on server  
> machine shows ES is consuming 1531MB of virtual memory. I do not have much  
> experience in JAVA, so am not familiar with tools to monitor JVM and such,  
> so pardon me if info I provide is insufficient. Here is the output of  
> running free -m on the machine.
> 
> deploy@elastic1:~$ free -m  
> total used free shared buffers cached  
> Mem: 496 488 8 0 5 23  
> -/+ buffers/cache: 459 36  
> Swap: 1023 568 455
> 
> I guess it should not be using such a huge amount of memory. First thing I  
> will do is decrease the number of shards from 5 to 1. Next I am planning to  
> migrate to ES 0.17.1(currently I am using 0.15.2), but it might take some  
> time before I migrate. What do you guys suggest I can do in meanwhile to  
> control this memory overflow?

---

<div class="post-metadata">

**Author:** ![Rubish\_Gupta](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Rubish\_Gupta](https://discuss.elastic.co/u/Rubish_Gupta)\
**Post date:** [July 22, 2011, 10:06pm UTC](https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926/3 "2011-07-22T22:06:08Z")

</div>

Yes I did use min/max memory, but I used MIN=256 and MAX=400. I will  
decrease the max memory.

But even then the overall stats on machine look a lot higher than what I  
have configured.

Are there any other commands on OS(ubuntu) or ES I can run to see exactly  
how much memory is taken by ES?

On Fri, Jul 22, 2011 at 8:01 PM, Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)wrote:

> did you specify the maximum and minimum memory?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elasticsearch-on-debian.html)
> 
> it should be
> 
> ES\_MIN\_MEM=256m  
> ES\_MAX\_MEM=256m
> 
> as approx the half of the available memory should be free for the OS  
> itself (to allow caching on OS-side)
> 
> And then only if ES requires more memory it'll throw OutOfMemoryError.  
> then you should either decrease memory usage or increase RAM 😉
> 
> On 22 Jul., 10:31, rubish gupta [rubish.gu...@almaconnect.com](mailto:rubish.gu...@almaconnect.com) wrote:
> 
> > Hi,
> > 
> > I have a small application which is growing slowly. I only index user and  
> > posts data in ES for now. I haven't configured shrads/index, so probably  
> > it  
> > is using default of 5 shards/index. I have ~6k users and \<1k posts till  
> > now.
> > 
> > The server is a 512MB server, only running ES. Right now htop on server  
> > machine shows ES is consuming 1531MB of virtual memory. I do not have  
> > much  
> > experience in JAVA, so am not familiar with tools to monitor JVM and  
> > such,  
> > so pardon me if info I provide is insufficient. Here is the output of  
> > running free -m on the machine.
> > 
> > deploy@elastic1:~$ free -m  
> > total used free shared buffers cached  
> > Mem: 496 488 8 0 5 23  
> > -/+ buffers/cache: 459 36  
> > Swap: 1023 568 455
> > 
> > I guess it should not be using such a huge amount of memory. First thing  
> > I  
> > will do is decrease the number of shards from 5 to 1. Next I am planning  
> > to  
> > migrate to ES 0.17.1(currently I am using 0.15.2), but it might take some  
> > time before I migrate. What do you guys suggest I can do in meanwhile to  
> > control this memory overflow?

---

<div class="post-metadata">

**Author:** ![danoyoung](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danoyoung](https://discuss.elastic.co/u/danoyoung)\
**Post date:** [July 22, 2011, 11:44pm UTC](https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926/4 "2011-07-22T23:44:17Z")

</div>

Check out jvisualvm or jmap

Regards,

Dan  
On Jul 22, 2011 4:06 PM, "rubish gupta" [rubish.gupta@almaconnect.com](mailto:rubish.gupta@almaconnect.com)  
wrote:

> Yes I did use min/max memory, but I used MIN=256 and MAX=400. I will  
> decrease the max memory.
> 
> But even then the overall stats on machine look a lot higher than what I  
> have configured.
> 
> Are there any other commands on OS(ubuntu) or ES I can run to see exactly  
> how much memory is taken by ES?
> 
> On Fri, Jul 22, 2011 at 8:01 PM, Karussell \<[tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)  
> wrote:
> 
> > did you specify the maximum and minimum memory?

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

> > it should be
> > 
> > ES\_MIN\_MEM=256m  
> > ES\_MAX\_MEM=256m
> > 
> > as approx the half of the available memory should be free for the OS  
> > itself (to allow caching on OS-side)
> > 
> > And then only if ES requires more memory it'll throw OutOfMemoryError.  
> > then you should either decrease memory usage or increase RAM 😉
> > 
> > On 22 Jul., 10:31, rubish gupta [rubish.gu...@almaconnect.com](mailto:rubish.gu...@almaconnect.com) wrote:
> > 
> > > Hi,
> > > 
> > > I have a small application which is growing slowly. I only index user  
> > > and  
> > > posts data in ES for now. I haven't configured shrads/index, so  
> > > probably  
> > > it  
> > > is using default of 5 shards/index. I have ~6k users and \<1k posts till  
> > > now.
> > > 
> > > The server is a 512MB server, only running ES. Right now htop on server  
> > > machine shows ES is consuming 1531MB of virtual memory. I do not have  
> > > much  
> > > experience in JAVA, so am not familiar with tools to monitor JVM and  
> > > such,  
> > > so pardon me if info I provide is insufficient. Here is the output of  
> > > running free -m on the machine.
> > > 
> > > deploy@elastic1:~$ free -m  
> > > total used free shared buffers cached  
> > > Mem: 496 488 8 0 5 23  
> > > -/+ buffers/cache: 459 36  
> > > Swap: 1023 568 455
> > > 
> > > I guess it should not be using such a huge amount of memory. First  
> > > thing  
> > > I  
> > > will do is decrease the number of shards from 5 to 1. Next I am  
> > > planning  
> > > to  
> > > migrate to ES 0.17.1(currently I am using 0.15.2), but it might take  
> > > some  
> > > time before I migrate. What do you guys suggest I can do in meanwhile  
> > > to  
> > > control this memory overflow?

---

<div class="post-metadata">

**Author:** ![Rubish\_Gupta](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Rubish\_Gupta](https://discuss.elastic.co/u/Rubish_Gupta)\
**Post date:** [July 23, 2011, 12:48am UTC](https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926/5 "2011-07-23T00:48:30Z")

</div>

I have gisted the output of jmap, top and free at  
[ES memory usage · GitHub](https://gist.github.com/1100776). Can somebody help me get some meaning  
attached to the outputs. Right now it is just some lines of text which I  
can't comprehend.

On Sat, Jul 23, 2011 at 5:14 AM, Dan Young [danoyoung@gmail.com](mailto:danoyoung@gmail.com) wrote:

> Check out jvisualvm or jmap
> 
> Regards,
> 
> Dan  
> On Jul 22, 2011 4:06 PM, "rubish gupta" [rubish.gupta@almaconnect.com](mailto:rubish.gupta@almaconnect.com)  
> wrote:
> 
> > Yes I did use min/max memory, but I used MIN=256 and MAX=400. I will  
> > decrease the max memory.
> > 
> > But even then the overall stats on machine look a lot higher than what I  
> > have configured.
> > 
> > Are there any other commands on OS(ubuntu) or ES I can run to see exactly  
> > how much memory is taken by ES?
> > 
> > On Fri, Jul 22, 2011 at 8:01 PM, Karussell \<[tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)  
> > wrote:
> > 
> > > did you specify the maximum and minimum memory?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elasticsearch-on-debian.html)
> 
> > > it should be
> > > 
> > > ES\_MIN\_MEM=256m  
> > > ES\_MAX\_MEM=256m
> > > 
> > > as approx the half of the available memory should be free for the OS  
> > > itself (to allow caching on OS-side)
> > > 
> > > And then only if ES requires more memory it'll throw OutOfMemoryError.  
> > > then you should either decrease memory usage or increase RAM 😉
> > > 
> > > On 22 Jul., 10:31, rubish gupta [rubish.gu...@almaconnect.com](mailto:rubish.gu...@almaconnect.com) wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I have a small application which is growing slowly. I only index user  
> > > > and  
> > > > posts data in ES for now. I haven't configured shrads/index, so  
> > > > probably  
> > > > it  
> > > > is using default of 5 shards/index. I have ~6k users and \<1k posts  
> > > > till  
> > > > now.
> > > > 
> > > > The server is a 512MB server, only running ES. Right now htop on  
> > > > server  
> > > > machine shows ES is consuming 1531MB of virtual memory. I do not have  
> > > > much  
> > > > experience in JAVA, so am not familiar with tools to monitor JVM and  
> > > > such,  
> > > > so pardon me if info I provide is insufficient. Here is the output of  
> > > > running free -m on the machine.
> > > > 
> > > > deploy@elastic1:~$ free -m  
> > > > total used free shared buffers cached  
> > > > Mem: 496 488 8 0 5 23  
> > > > -/+ buffers/cache: 459 36  
> > > > Swap: 1023 568 455
> > > > 
> > > > I guess it should not be using such a huge amount of memory. First  
> > > > thing  
> > > > I  
> > > > will do is decrease the number of shards from 5 to 1. Next I am  
> > > > planning  
> > > > to  
> > > > migrate to ES 0.17.1(currently I am using 0.15.2), but it might take  
> > > > some  
> > > > time before I migrate. What do you guys suggest I can do in meanwhile  
> > > > to  
> > > > control this memory overflow?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 24, 2011, 2:44am UTC](https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926/6 "2011-07-24T02:44:29Z")

</div>

Even if you specify MIN and MAX memory, those apply to the JVM heap size,  
there is still an overhead associated with the java process itself, though,  
based on your usage, it should be constant so you can extrapolate what it  
is.

On Sat, Jul 23, 2011 at 3:48 AM, rubish gupta  
[rubish.gupta@almaconnect.com](mailto:rubish.gupta@almaconnect.com)wrote:

> I have gisted the output of jmap, top and free at  
> [ES memory usage · GitHub](https://gist.github.com/1100776). Can somebody help me get some meaning  
> attached to the outputs. Right now it is just some lines of text which I  
> can't comprehend.
> 
> On Sat, Jul 23, 2011 at 5:14 AM, Dan Young [danoyoung@gmail.com](mailto:danoyoung@gmail.com) wrote:
> 
> > Check out jvisualvm or jmap
> > 
> > Regards,
> > 
> > Dan  
> > On Jul 22, 2011 4:06 PM, "rubish gupta" [rubish.gupta@almaconnect.com](mailto:rubish.gupta@almaconnect.com)  
> > wrote:
> > 
> > > Yes I did use min/max memory, but I used MIN=256 and MAX=400. I will  
> > > decrease the max memory.
> > > 
> > > But even then the overall stats on machine look a lot higher than what I  
> > > have configured.
> > > 
> > > Are there any other commands on OS(ubuntu) or ES I can run to see  
> > > exactly  
> > > how much memory is taken by ES?
> > > 
> > > On Fri, Jul 22, 2011 at 8:01 PM, Karussell \<  
> > > [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)\>wrote:
> > > 
> > > > did you specify the maximum and minimum memory?
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elasticsearch-on-debian.html)
> > 
> > > > it should be
> > > > 
> > > > ES\_MIN\_MEM=256m  
> > > > ES\_MAX\_MEM=256m
> > > > 
> > > > as approx the half of the available memory should be free for the OS  
> > > > itself (to allow caching on OS-side)
> > > > 
> > > > And then only if ES requires more memory it'll throw OutOfMemoryError.  
> > > > then you should either decrease memory usage or increase RAM 😉
> > > > 
> > > > On 22 Jul., 10:31, rubish gupta [rubish.gu...@almaconnect.com](mailto:rubish.gu...@almaconnect.com) wrote:
> > > > 
> > > > > Hi,
> > > > > 
> > > > > I have a small application which is growing slowly. I only index user  
> > > > > and  
> > > > > posts data in ES for now. I haven't configured shrads/index, so  
> > > > > probably  
> > > > > it  
> > > > > is using default of 5 shards/index. I have ~6k users and \<1k posts  
> > > > > till  
> > > > > now.
> > > > > 
> > > > > The server is a 512MB server, only running ES. Right now htop on  
> > > > > server  
> > > > > machine shows ES is consuming 1531MB of virtual memory. I do not have  
> > > > > much  
> > > > > experience in JAVA, so am not familiar with tools to monitor JVM and  
> > > > > such,  
> > > > > so pardon me if info I provide is insufficient. Here is the output of  
> > > > > running free -m on the machine.
> > > > > 
> > > > > deploy@elastic1:~$ free -m  
> > > > > total used free shared buffers cached  
> > > > > Mem: 496 488 8 0 5 23  
> > > > > -/+ buffers/cache: 459 36  
> > > > > Swap: 1023 568 455
> > > > > 
> > > > > I guess it should not be using such a huge amount of memory. First  
> > > > > thing  
> > > > > I  
> > > > > will do is decrease the number of shards from 5 to 1. Next I am  
> > > > > planning  
> > > > > to  
> > > > > migrate to ES 0.17.1(currently I am using 0.15.2), but it might take  
> > > > > some  
> > > > > time before I migrate. What do you guys suggest I can do in meanwhile  
> > > > > to  
> > > > > control this memory overflow?

---

<div class="post-metadata">

**Author:** ![ofavre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ofavre/32/116819_2.png) [@ofavre](https://discuss.elastic.co/u/ofavre)\
**Post date:** [July 25, 2011, 7:57am UTC](https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926/7 "2011-07-25T07:57:17Z")

</div>

Are you talking of **virtual** memory?  
This has nothing to do with the real memory usage, ie _resident_ memory (if  
you have no swapping).

Let me explain:  
Let's assume you have a 100 GB index stored on the disk, and for performance  
reasons, you are using index.store.type=mmap.  
Let's assume then that you have successfully configured ES to use 10 GB of  
RAM.  
You would end up having a memory usage as follows:  
RES (resident memory) = 10.4 GB  
VIRT (virtual memory) = 110.4 GB  
And I am very far from having that much memory in RAM and in the swap !  
The virtual memory used by mmap is... virtual. It does a projection of the  
files into the process memory addressing, but the OS under the hood, only  
mounts parts of the file into memory, as it sees can fit into the cache.  
(well, I'm not 100% sure of that...)  
This is also why you should let some RAM to the OS for its caching.

Remember: virtual memory is... strange, and does not reflect the RAM usage.  
Look at the resident memory.  
(Not sure where the swap usage stands, and I now that there is no exact  
calculation of that under linux given the resident and virtual memory  
usage).

## Cheers,

Olivier Favre

[www.yakaz.com](http://www.yakaz.com)

2011/7/22 rubish gupta [rubish.gupta@almaconnect.com](mailto:rubish.gupta@almaconnect.com)

> Hi,
> 
> I have a small application which is growing slowly. I only index user and  
> posts data in ES for now. I haven't configured shrads/index, so probably it  
> is using default of 5 shards/index. I have ~6k users and \<1k posts till  
> now.
> 
> The server is a 512MB server, only running ES. Right now htop on server  
> machine shows ES is consuming 1531MB of virtual memory. I do not have much  
> experience in JAVA, so am not familiar with tools to monitor JVM and such,  
> so pardon me if info I provide is insufficient. Here is the output of  
> running free -m on the machine.
> 
> deploy@elastic1:~$ free -m  
> total used free shared buffers cached  
> Mem: 496 488 8 0 5 23  
> -/+ buffers/cache: 459 36  
> Swap: 1023 568 455
> 
> I guess it should not be using such a huge amount of memory. First thing I  
> will do is decrease the number of shards from 5 to 1. Next I am planning to  
> migrate to ES 0.17.1(currently I am using 0.15.2), but it might take some  
> time before I migrate. What do you guys suggest I can do in meanwhile to  
> control this memory overflow?

---

<div class="post-metadata">

**Author:** ![Rubish\_Gupta](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Rubish\_Gupta](https://discuss.elastic.co/u/Rubish_Gupta)\
**Post date:** [July 25, 2011, 4:07pm UTC](https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926/8 "2011-07-25T16:07:28Z")

</div>

Thanks for the clarification on virtual memory. It makes much more sense  
now.

On Mon, Jul 25, 2011 at 1:27 PM, Olivier Favre [olivier@yakaz.com](mailto:olivier@yakaz.com) wrote:

> Are you talking of **virtual** memory?  
> This has nothing to do with the real memory usage, ie _resident_ memory  
> (if you have no swapping).
> 
> Let me explain:  
> Let's assume you have a 100 GB index stored on the disk, and for  
> performance reasons, you are using index.store.type=mmap.  
> Let's assume then that you have successfully configured ES to use 10 GB of  
> RAM.  
> You would end up having a memory usage as follows:  
> RES (resident memory) = 10.4 GB  
> VIRT (virtual memory) = 110.4 GB  
> And I am very far from having that much memory in RAM and in the swap !  
> The virtual memory used by mmap is... virtual. It does a projection of the  
> files into the process memory addressing, but the OS under the hood, only  
> mounts parts of the file into memory, as it sees can fit into the cache.  
> (well, I'm not 100% sure of that...)  
> This is also why you should let some RAM to the OS for its caching.
> 
> Remember: virtual memory is... strange, and does not reflect the RAM usage.  
> Look at the resident memory.  
> (Not sure where the swap usage stands, and I now that there is no exact  
> calculation of that under linux given the resident and virtual memory  
> usage).
> 
> ## Cheers,
> 
> Olivier Favre
> 
> [www.yakaz.com](http://www.yakaz.com)
> 
> 2011/7/22 rubish gupta [rubish.gupta@almaconnect.com](mailto:rubish.gupta@almaconnect.com)
> 
> > Hi,
> > 
> > I have a small application which is growing slowly. I only index user and  
> > posts data in ES for now. I haven't configured shrads/index, so probably it  
> > is using default of 5 shards/index. I have ~6k users and \<1k posts till  
> > now.
> > 
> > The server is a 512MB server, only running ES. Right now htop on server  
> > machine shows ES is consuming 1531MB of virtual memory. I do not have much  
> > experience in JAVA, so am not familiar with tools to monitor JVM and such,  
> > so pardon me if info I provide is insufficient. Here is the output of  
> > running free -m on the machine.
> > 
> > deploy@elastic1:~$ free -m  
> > total used free shared buffers cached  
> > Mem: 496 488 8 0 5 23  
> > -/+ buffers/cache: 459 36  
> > Swap: 1023 568 455
> > 
> > I guess it should not be using such a huge amount of memory. First thing I  
> > will do is decrease the number of shards from 5 to 1. Next I am planning to  
> > migrate to ES 0.17.1(currently I am using 0.15.2), but it might take some  
> > time before I migrate. What do you guys suggest I can do in meanwhile to  
> > control this memory overflow?

---

<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:59am UTC](https://discuss.elastic.co/t/very-small-es-instance-consuming-too-much-memory/4926/9 "2017-07-06T03:59:33Z")

</div>


