Could not reserve enough space for 2097152KB object heap

We have set up a Windows Server 2022 datacenter for our SonarQube Enterprise, to test it in Windows Server environment. Machine has 2 vcpus as well as 8 GB of RAM. I did test the community edition and it did work, but enterprise does not. What should we adjust? We are trying to run the zip package scenario.

Starting SonarQube...
2024.04.30 09:56:29 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory C:\sonarqube-10.5.0.89998\temp
2024.04.30 09:56:29 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:55533]
2024.04.30 09:56:29 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [C:\sonarqube-10.5.0.89998\elasticsearch]: C:\Program Files (x86)\Eclipse Adoptium\jdk-17.0.10.7-hotspot\bin\java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=./bin/elasticsearch -Dcli.libs=lib/tools/server-cli -Des.path.home=C:\sonarqube-10.5.0.89998\elasticsearch -Des.path.conf=C:\sonarqube-10.5.0.89998\temp\conf\es -Des.distribution.type=tar -cp C:\sonarqube-10.5.0.89998\elasticsearch\lib\*;C:\sonarqube-10.5.0.89998\elasticsearch\lib\cli-launcher\* org.elasticsearch.launcher.CliToolLauncher
2024.04.30 09:56:29 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]
output:
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
error:

        at org.elasticsearch.server.cli.JvmOption.flagsFinal(JvmOption.java:120)
        at org.elasticsearch.server.cli.JvmOption.findFinalOptions(JvmOption.java:87)
        at org.elasticsearch.server.cli.MachineDependentHeap.determineHeapSettings(MachineDependentHeap.java:59)
        at org.elasticsearch.server.cli.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:138)
        at org.elasticsearch.server.cli.JvmOptionsParser.determineJvmOptions(JvmOptionsParser.java:91)
        at org.elasticsearch.server.cli.ServerProcess.createProcess(ServerProcess.java:208)
        at org.elasticsearch.server.cli.ServerProcess.start(ServerProcess.java:104)
        at org.elasticsearch.server.cli.ServerProcess.start(ServerProcess.java:88)
        at org.elasticsearch.server.cli.ServerCli.startServer(ServerCli.java:239)
        at org.elasticsearch.server.cli.ServerCli.execute(ServerCli.java:100)
        at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:54)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)
        at org.elasticsearch.cli.Command.main(Command.java:50)
        at org.elasticsearch.launcher.CliToolLauncher.main(CliToolLauncher.java:64)
2024.04.30 09:56:33 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [ElasticSearch]: 1
2024.04.30 09:56:33 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2024.04.30 09:56:33 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped

Hey there.

The Enterprise Edition comes with higher defaults for JVM Heaps (which can be configured in your conf/sonar.properties file) to be ready for enterprise workloads.

In any case, it seems that your server has less than 2 GB of RAM free by the time it starts up Elasticsearch. Ideally, you would bump up the server RAM.

See the docs here on Enterprise Hardware Reccomendations:

For large teams or enterprise-scale installations of SonarQube, additional hardware is required. At the enterprise level, monitoring your SonarQube instance is essential and should guide further hardware upgrades as your instance grows. A starting configuration should include at least:

  • 8 cores, to allow the main SonarQube platform to run with multiple compute engine workers
  • 16GB of RAM For additional requirements and recommendations relating to database and Elasticsearch, see Hardware recommendations.
1 Like

Thanks @Colin. Was just about testing the Enterprise, but I think I can scale up the machine to for the tests. Thanks!

@Colin so I have scaled up the machine to 8 CPU’s and 16GB’s of RAM, but I still get ther error. Do you guys have some extended step by step configuration on how to install and confgure the Enterprise versions? Would appreciate a lot.

Starting SonarQube...
2024.05.15 12:52:06 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory C:\sonarqube-10.5.0.89998\var\sonarqube\temp
2024.05.15 12:52:06 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:53262]
2024.05.15 12:52:07 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [C:\sonarqube-10.5.0.89998\elasticsearch]: C:\Program Files (x86)\Eclipse Adoptium\jdk-17.0.10.7-hotspot\bin\java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=./bin/elasticsearch -Dcli.libs=lib/tools/server-cli -Des.path.home=C:\sonarqube-10.5.0.89998\elasticsearch -Des.path.conf=C:\sonarqube-10.5.0.89998\var\sonarqube\temp\conf\es -Des.distribution.type=tar -cp C:\sonarqube-10.5.0.89998\elasticsearch\lib\*;C:\sonarqube-10.5.0.89998\elasticsearch\lib\cli-launcher\* org.elasticsearch.launcher.CliToolLauncher
2024.05.15 12:52:07 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2024.05.15 12:52:24 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
2024.05.15 12:52:24 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[WEB_SERVER] from [C:\sonarqube-10.5.0.89998]: C:\Program Files (x86)\Eclipse Adoptium\jdk-17.0.10.7-hotspot\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=C:\sonarqube-10.5.0.89998\var\sonarqube\temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED -Dcom.redhat.fips=false -Xmx1G -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-10.5.0.89998.jar;C:\sonarqube-10.5.0.89998\lib\jdbc\h2\h2-2.2.224.jar org.sonar.server.app.WebServer C:\sonarqube-10.5.0.89998\var\sonarqube\temp\sq-process9047676605127842344properties
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.sonar.process.PluginSecurityManager (file:/C:/sonarqube-10.5.0.89998/lib/sonar-application-10.5.0.89998.jar)
WARNING: Please consider reporting this to the maintainers of org.sonar.process.PluginSecurityManager
WARNING: System::setSecurityManager will be removed in a future release
2024.05.15 12:52:36 INFO  app[][o.s.a.SchedulerImpl] Process[web] is up
2024.05.15 12:52:36 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[COMPUTE_ENGINE] from [C:\sonarqube-10.5.0.89998]: C:\Program Files (x86)\Eclipse Adoptium\jdk-17.0.10.7-hotspot\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=C:\sonarqube-10.5.0.89998\var\sonarqube\temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED -Dcom.redhat.fips=false -Xmx2G -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-10.5.0.89998.jar;C:\sonarqube-10.5.0.89998\lib\jdbc\h2\h2-2.2.224.jar org.sonar.ce.app.CeServer C:\sonarqube-10.5.0.89998\var\sonarqube\temp\sq-process4194401351745934669properties
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
2024.05.15 12:52:36 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [Compute Engine]: 1
2024.05.15 12:52:36 INFO  app[][o.s.a.SchedulerImpl] Process[Compute Engine] is stopped
2024.05.15 12:52:38 INFO  app[][o.s.a.SchedulerImpl] Process[Web Server] is stopped
2024.05.15 12:52:38 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2024.05.15 12:52:38 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped

The issue here really seems to be related to free memory.

How much free memory do you have?

Hi @Colin here’s some information that might help.

image

So, it does look that there’s a plenty of space. Also, this is a pure installation, no projects connected, started from clean.

Some configuration information that might help to understand what is wrong here.

# WEB SERVER
sonar.web.javaOpts=-Xmx1G -Xms128m -XX:+HeapDumpOnOutOfMemoryError

# COMPUTE ENGINE
sonar.ce.javaOpts=-Xmx2G -Xms128m -XX:+HeapDumpOnOutOfMemoryError

# ELASTICSEARCH
# JVM options of Elasticsearch process
sonar.search.javaOpts=-Xmx1G -Xms1G -XX:MaxDirectMemorySize=1G -XX:+HeapDumpOnOutOfMemoryError

Much appreciated!

@anon67236913 any suggestions you might add here? I know you have a similar setup :slight_smile: Would appreciate a lot.

Hi,

Sonarqube Enterprise 10.5.1 runs on a VM

  • Windows Server 2019
  • 12 CPU
  • 24G RAM
  • Partition 100G

with sonar configuration

4 CE workers

sonar.web.javaOpts=-server -Xmx2G -Xms128m -XX:+HeapDumpOnOutOfMemoryError
sonar.ce.javaOpts=-server -Xmx8G -Xms512m -Xss1G -XX:+HeapDumpOnOutOfMemoryError
sonar.search.javaOpts=-Xmx3G -Xms3G -XX:MaxDirectMemorySize=1G -XX:+HeapDumpOnOutOfMemoryError

I think your configuration with only 2 CPU and 8G ram is much too small for a Sonarqube Enterprise instance.

Gilbert

1 Like

Adjusted the settings, but I still have the same issue.

Is it possible you’re using a 32bit JDK !?

2024.04.30 09:56:29 INFO app[o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [C:\sonarqube-10.5.0.89998\elasticsearch]: C:\Program Files (x86)\Eclipse Adoptium\jdk-17.0.10.7-hotspot\bin\java -Xms4m -Xmx64m

32-bit JVM limitations: On 32-bit systems, the JVM is limited to addressing a maximum of around 1.5-1.6 GB of contiguous memory space for the heap. If you try to allocate more than this limit, the JVM will fail to initialize.

Switch to a 64bit JVM and try again.

Alright, seems I did install the wrong version at firs, as that was old. I did install JDK 17 and set the sonar path to that installation. Thank you guys so far.

Means the solution was to switch from a 32bit JDK 17 to a 64bit JDK 17 as i proposed ?

I did install the wrong version, but coming out of your reply, I did download the 64 bit version 17 and installed that, plus I have updated the SONAR PATH to java, as well as adjusted the sonar.conf according to your advice. So, big thanks to you my friend! :slight_smile: