# Cannot allocate memory error despite enough memory

**URL:** <https://discuss.elastic.co/t/cannot-allocate-memory-error-despite-enough-memory/95431>\
**Category:** Elasticsearch\
**Created:** [August 2, 2017, 12:12am UTC](https://discuss.elastic.co/t/cannot-allocate-memory-error-despite-enough-memory/95431 "2017-08-02T00:12:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![thefourtheye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thefourtheye/32/8414_2.png) [@thefourtheye](https://discuss.elastic.co/u/thefourtheye)\
**Post date:** [August 2, 2017, 12:12am UTC](https://discuss.elastic.co/t/cannot-allocate-memory-error-despite-enough-memory/95431/1 "2017-08-02T00:12:53Z")

</div>

My machine has a 24G RAM.

```
$ free -h
             total used free shared buffers cached
Mem: 23G 257M 23G 0B 12M 39M
-/+ buffers/cache: 206M 23G
Swap: 2.0G 21M 2.0G

```

And

```
$ echo $ES_HEAP_SIZE
12g

```

But still when I start elasticsearch it says that

```
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000004e9990000, 12187009024, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 12187009024 bytes for committing reserved memory.

```

I use elasticsearch 2.4.4. Following are the system configurations which might help in find the problem.

```
$ tail /etc/sysctl.conf

#Controls the maximum number of map count
vm.max_map_count=262144
vm.min_free_kbytes=24794496
vm.swappiness=1
fs.file-max = 100000

```

and

```
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 96030
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 210000
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 4096
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
```

---

<div class="post-metadata">

**Author:** ![thefourtheye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thefourtheye/32/8414_2.png) [@thefourtheye](https://discuss.elastic.co/u/thefourtheye)\
**Post date:** [August 3, 2017, 4:41pm UTC](https://discuss.elastic.co/t/cannot-allocate-memory-error-despite-enough-memory/95431/2 "2017-08-03T16:41:55Z")

</div>

bump

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 4, 2017, 7:10am UTC](https://discuss.elastic.co/t/cannot-allocate-memory-error-despite-enough-memory/95431/3 "2017-08-04T07:10:26Z")

</div>

please be aware that this is a public forum without any SLAs when bumping threads.

Have you enabled memory locking in Elasticsearch? I see it is set to unlimited in the ulimit output, but there is more than one configuration option to ensure this (depends on the distribution). If it is enabled, disable it, to check if that is the cuplrit.

Any other changes you did? JVM options, startup options or general configuration?

--Alex

---

<div class="post-metadata">

**Author:** ![thefourtheye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thefourtheye/32/8414_2.png) [@thefourtheye](https://discuss.elastic.co/u/thefourtheye)\
**Post date:** [August 9, 2017, 6:48pm UTC](https://discuss.elastic.co/t/cannot-allocate-memory-error-despite-enough-memory/95431/4 "2017-08-09T18:48:47Z")

</div>

> please be aware that this is a public forum without any SLAs when bumping threads.

Oh, sorry about that.

I am writing to say that this problem is solved. This elasticsearch instance is running in a VM, and it had a specific configuration which made the operating system to keep all the 24GB free it seems.

`/proc/sys/vm/min_free_kbytes` file had the value `24794496`. I changed it to a much lower value, and it started working.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 10, 2017, 6:52am UTC](https://discuss.elastic.co/t/cannot-allocate-memory-error-despite-enough-memory/95431/5 "2017-08-10T06:52:55Z")

</div>

out of curiosity and to help users in the future. Who was configuring this setting to that value? The operating system with some automation or the sysadmin?

---

<div class="post-metadata">

**Author:** ![thefourtheye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thefourtheye/32/8414_2.png) [@thefourtheye](https://discuss.elastic.co/u/thefourtheye)\
**Post date:** [August 10, 2017, 7:09am UTC](https://discuss.elastic.co/t/cannot-allocate-memory-error-despite-enough-memory/95431/6 "2017-08-10T07:09:01Z")

</div>

I am not very sure. This was a brand new VM, created 15 mins before I tried to install elasticsearch. So I am guessing, when it was created some configuration value was wrong, but I could be wrong. Sorry, thats the best information I could give.

---

<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 7, 2017, 7:09am UTC](https://discuss.elastic.co/t/cannot-allocate-memory-error-despite-enough-memory/95431/7 "2017-09-07T07:09:18Z")

</div>

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