7

A am trying to build and sbt 0.13.13 docker image similar to this one. Running java $JAVA_OPTS -jar sbt-launch.jar (as a step of building the image) fails with:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000d3026000, 451256320, 0) failed; error='Out of memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 451256320 bytes for committing 
reserved memory.

Increasing -Xmx doesn' help. What can I do to fix this? This is the Dockerfile: https://github.com/kolov/k8s-stuff/blob/master/scala/Dockerfile

Alexander Azarov
  • 12,971
  • 2
  • 50
  • 54
Assen Kolov
  • 4,143
  • 2
  • 22
  • 32
  • what are the JAVA_OPS? It looks like you're trying to allocate 430MB of memory – gusto2 Jul 16 '17 at 14:06
  • -Xms512M -Xmx2048M – Assen Kolov Jul 16 '17 at 14:11
  • 2
    @AssenKolov please can you add the output of `docker info` that will give you the total memory available to docker while building the image, incase if the memory is lower that what you are expecting while building your program. – vedarthk Jul 16 '17 at 20:39
  • 2
    Thanks a lot,@vedarth. Your suggestion helped to pinpoint the real problem and finding the solution from there was easy: https://stackoverflow.com/questions/32834082/how-to-increase-docker-machine-memory-mac – Assen Kolov Jul 17 '17 at 07:19
  • Possible duplicate of [How to increase docker-machine memory Mac](https://stackoverflow.com/questions/32834082/how-to-increase-docker-machine-memory-mac) – Alexander Azarov Jul 17 '17 at 17:07

1 Answers1

4

Increase the swap space of the hardisk using the following commands

sudo dd if=/dev/zero of=/var/myswap bs=1M count=2048

sudo mkswap /var/myswap

sudo swapon /var/myswap
Zoe
  • 27,060
  • 21
  • 118
  • 148
ramnar
  • 146
  • 1
  • 8