Docker Community Forums

Share and learn in the Docker community.

Can not allocate enough memory from image with java app

DockerToolbox 1.12.3 on Windows. My image contains java app. When I allocate JVM heap as -Xms1g -Xmx2g then the app starts properly, but can not use memory more than 1G. If I start the app with settings ‘-Xms2g -Xmx2g’ then the app cannot even start throwing error:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000084000000, 2080374784, 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 2080374784 bytes for committing reserved memory.

I do have more than 4G free mem on the host.
How can I solve this issue?

Thanks, Denis.

Probably the VM does not have enough memory.

You can either create a new one and set the memory available using --virtualbox-memory flag, or power the VM down (docker-machine stop) then go edit the memory provisioned in the VirtualBox GUI manually.

Yep, it helps. Thank you so much!