Error 'Not enough space' de OpenJDK en Digital Ocean
A very common error when starting with Digital Ocean is that when installing almost any Java-based program such as SonarQube, you immediately get a memory space error. In my case, when starting the SonarQube service, I obtained an error similar to the following.
Running SonarQube...
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 |
jvm 1 | 2020.01.06 17:26:13 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /var/opt/sonarqube-8/temp
jvm 1 | 2020.01.06 17:26:13 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
jvm 1 | 2020.01.06 17:26:13 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/var/opt/sonarqube-8/elasticsearch]: /var/opt/sonarqube-8/elasticsearch/bin/elasticsearch
jvm 1 | 2020.01.06 17:26:13 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
jvm 1 | OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
jvm 1 | 2020.01.06 17:26:14 INFO app[][o.e.p.PluginsService] no modules loaded
jvm 1 | 2020.01.06 17:26:14 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
jvm 1 | OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000e5330000, 449642496, 0) failed; error='Not enough space' (errno=12)
jvm 1 | #
jvm 1 | # There is insufficient memory for the Java Runtime Environment to continue.
jvm 1 | # Native memory allocation (mmap) failed to map 449642496 bytes for committing reserved memory.
jvm 1 | # An error report file with more information is saved as:
jvm 1 | # ../logs/es_hs_err_pid6724.log
jvm 1 | 2020.01.06 17:26:14 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1
jvm 1 | 2020.01.06 17:26:14 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped
jvm 1 | 2020.01.06 17:26:14 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
jvm 1 | 2020.01.06 17:26:16 INFO app[][o.e.c.t.TransportClientNodesService] failed to get node info for {#transport#-1}{d6qtSSpxQdmKK7HdJgDjIQ}{127.0.0.1}{127.0.0.1:9001}, disconnecting...
jvm 1 | java.lang.IllegalStateException: Future got interrupted
...
jvm 1 | ... 17 common frames omitted
wrapper | <-- Wrapper Stopped
It is important to learn to read errors and really find the cause. In this case, the most important line that tells us the origin of the error is the following:
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000e5330000, 449642496, 0) failed; error='Not enough space' (errno=12)
Undoubtedly, by reading this error, we can clearly understand what is happening, and it is nothing more than OpenJDK not having enough memory to run the virtual machine and run SonarQube. It is well known that Java's virtual machine consumes a lot of server resources. Another important point here is to see the amount of memory that has not been able to be allocated. In this case, the following line tells us how much memory is missing to run our program.
# Native memory allocation (mmap) failed to map 449642496 bytes for committing reserved memory.
By doing the conversion we realize that we are missing around 449.64 MB of RAM. With this, we can calmly enter our account on Digital Ocean, select our Droplet, and in the Resize option select CPU and RAM Only, and then select the appropriate plan according to our needs. I hope this post has been helpful to you, see you soon!.