1

I am trying to learn Scala so I installed openjdk-8-jdk on my Ubuntu machine, and proceeded to install sbt.

sudo apt-get install openjdk-8-jdk
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
sudo apt-get update
sudo apt-get install sbt

Unfortunately, after the sbt installation, when I typed 'sbt about' to check it, it retrieved the following error:

~$ sbt about
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000d5550000, 715849728, 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 715849728 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/antonio/hs_err_pid14103.log

Could anybody tell me what is the problem? I am not an experienced programmer and I have not found this question anywhere, perhaps because it is too basic.

Thanks!

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Toni.M
  • 53
  • 4
  • 1
    How much physical memory does your system have? Do you have any swap configured? `cat /proc/meminfo` can provide this information. It looks like sbt is trying to reserve a heap of ~700mb and the operating system is saying it doesn't have it. – Michael Powers Sep 05 '18 at 13:23
  • 1
    *There is insufficient memory for the Java Runtime Environment to continue.* IMHO thats self explainatory. – Antoniossss Sep 05 '18 at 13:59
  • Scala can be built with Maven or Gradle too, btw – OneCricketeer Sep 05 '18 at 14:04
  • Not an official comment, but everyone I know in Scala only tests on Java 8. Your error is not enough memory. However, trying to allocate 700+ MB of memory is strange for `sbt about` unless you are on a tiny system (T2 micro on AWS?) – John Hanley Sep 05 '18 at 14:50
  • I often use sbt with open-jdk-8 on Centos without any problems, so I'm sure your open-jdk is perfectly fine with sbt. Since its the first time you run sbt, it'll start downloading all sorts of jars (including the sbt and the scala compiler) - this process does need some memory. If indeed your machine is short on memory, the JVM will run with a small heap which can cause such a failure. You can use ```java -XX:+PrintFlagsFinal -version | grep HeapSize``` to determine how much memory the JVM can use, then try to increase it. See this thread: https://stackoverflow.com/questions/28272923 – Michael Yakobi Sep 05 '18 at 19:33

1 Answers1

2

Finally, it was a problem with insufficient RAM memory. Since I am using a Virtual Machine, I just added some RAM memory and it worked perfectly.

Thank you for your feedback!

Toni.M
  • 53
  • 4