Skip to content
This repository has been archived by the owner. It is now read-only.

Memory Allocation Issue #43

Closed
waytoharish opened this issue Mar 24, 2017 · 10 comments
Closed

Memory Allocation Issue #43

waytoharish opened this issue Mar 24, 2017 · 10 comments

Comments

@waytoharish
Copy link

@waytoharish waytoharish commented Mar 24, 2017

Getting this error on Docker-

There is insufficient memory for the Java Runtime Environment to continue.

Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.

An error report file with more information is saved as:

/tmp/hs_err_pid1.log

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)

Running Command-docker run --name elasticsearch -d -p 9200:9200 elasticsearch -e ES_JAVA_OPTS="-Xms2g -Xmx2g"

@dliappis
Copy link
Contributor

@dliappis dliappis commented Mar 25, 2017

@waytoharish Note that we appreciate providing the output of docker info as well as information about what operating system your are running docker on, as mentioned in the issue template, so that we can troubleshoot issues efficiently.

The error you are seeing basically means that the operating system where docker runs didn't have 2GB of available memory to facilitate your ES container. If you are running docker natively on Mac or Windows (that's why we need the above info), note that in practice there is a Linux VM where your containers run and this has a limited amount of system ram allocated to it by default. You can adjust the memory allocated to Docker e.g. on Docker for Mac here.

@waytoharish
Copy link
Author

@waytoharish waytoharish commented Mar 27, 2017

I am running Docker on Window.Below is requested information
$ docker info
Containers: 2
Running: 2
Paused: 0
Stopped: 0
Images: 34
Server Version: 17.03.0-ce
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 120
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.52-boot2docker
Operating System: Boot2Docker 17.03.0-ce (TCL 7.2); HEAD : f11a204 - Thu Mar 2 00:14:47 UTC 2017
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.8 MiB
Name: default
ID: KFMQ:PDCN:563P:GGOO:7Z7W:WMTM:2VPK:E4KF:SKYL:WNJ4:CNBV:ZOTG
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 26
Goroutines: 31
System Time: 2017-03-27T06:30:18.558026155Z
EventsListeners: 0
Registry: https://index.docker.io/v1/
Labels:
provider=virtualbox
Insecure Registries:
127.0.0.0/8

@dliappis
Copy link
Contributor

@dliappis dliappis commented Mar 27, 2017

I see:

Total Memory: 995.8 MiB

You should either increase the memory allocated for Docker and/or decrease the heapsize configured for Elasticsearch e.g.:

... -e ES_JAVA_OPTS="-Xms512m -Xmx512m"

@waytoharish
Copy link
Author

@waytoharish waytoharish commented Mar 27, 2017

I am running this command still same error-
docker run -p 9200:9200 -e ES_JAVA_OPTS="-Xms2g -Xmx2g" -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/elasticsearch:5.2.2

@dliappis
Copy link
Contributor

@dliappis dliappis commented Mar 27, 2017

Given your memory situation, you should run instead:

docker run -p 9200:9200 -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/elasticsearch:5.2.2

@waytoharish
Copy link
Author

@waytoharish waytoharish commented Mar 27, 2017

thanks seams working fine now

@jobwat jobwat mentioned this issue Jun 30, 2017
@ebuildy
Copy link

@ebuildy ebuildy commented Nov 13, 2017

This is no more working since 5.6, you must edit jvm.options file.

See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html

By default, it's 2Gb, since values are hardcoded, define them via environment variables have no effect.

@dliappis
Copy link
Contributor

@dliappis dliappis commented Nov 13, 2017

@ebuildy The setting should be working still. In fact we have tests for it (see here and here), so if doesn't work, it's a test bug. I tested interactively again now, though, using:

docker run -p 9200:9200 -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:5.6.4

which confirms things are working as expected:

Digest: sha256:0b2d4a4aef96ec4f83b487af6cce7e049125ea4996eec4b5b1ce0aa23a859f54
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:5.6.4
[2017-11-13T17:32:35,215][INFO ][o.e.n.Node               ] [] initializing ...
[2017-11-13T17:32:35,280][INFO ][o.e.e.NodeEnvironment    ] [eeyXt0n] using [1] data paths, mounts [[/ (overlay)]], net usable_space [14.2gb], net total_space [18.5gb], spins? [possibly], types [overlay]
[2017-11-13T17:32:35,280][INFO ][o.e.e.NodeEnvironment    ] [eeyXt0n] heap size [495.3mb], compressed ordinary object pointers [true]

This can also be confirmed using:

$ curl -s -u elastic:changeme localhost:9200/_nodes/stats | jq . | grep heap_max_in_bytes   
          "heap_max_in_bytes": 519438336,

@zella
Copy link

@zella zella commented May 8, 2018

What about -XX:+UseCGroupMemoryLimitForHeap?

docker run -m 500MB -p 9200:9200 -e ES_JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XshowSettings:vm" elasticsearch

I have same issue with it.

@chris530
Copy link

@chris530 chris530 commented Sep 6, 2018

@zella thanks !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants