SonarQube analysis failed java.lang.OutOfMemoryError: Java heap space

7,297 views
Skip to first unread message

Вадим Самойленко

unread,
Oct 3, 2017, 1:23:42 AM10/3/17
to SonarQube
Hello! 
I have a big esql project. When sonar-scanner is done i get message:

INFO: Analysis report generated in 6954ms, dir size=207 MB
INFO: Analysis reports compressed in 26271ms, zip size=75 MB  ######### (NOT SO MUCH)!!!!
INFO: Analysis report uploaded in 3469ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://MYHOST:9000/dashboard/index/Federal_00

My project trying to be load in SonarQube, but every time get fail.
In log file in SonarQube I can see:

java.lang.OutOfMemoryError: Java heap space

I realized thet problem in java memory. I whole night was tryng to change this lines in sonar.properties

sonar.ce.javaOpts=-Xmx2048m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true
sonar.web.javaOpts=-Xmx2048m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true
sonar.search.javaOpts=-Xmx2048G -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true \
  -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 \
  -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError

but not successful. Sometimes i get java.lang.OutOfMemoryError: GC overhead limit exceeded. I can't understand what I do wrong.

How can i resolve the problem?




seet...@gmail.com

unread,
Oct 3, 2017, 5:15:07 AM10/3/17
to SonarQube
Hello 


Which version of JDK are you using? This is a typical JDK 1.7 and below issue. You need to increase the PermGen, XMX and XMS settings to 4G to get rid of this issue

Regards,

Seetesh

Вадим Самойленко

unread,
Oct 3, 2017, 4:27:45 PM10/3/17
to SonarQube
As you can see I'm using  java 8.
Look at my java property. I used java -version command:

# java -XX:+PrintFlagsFinal -version | grep HeapSize
    uintx ErgoHeapSizeLimit                         = 0                                             {product}
    uintx HeapSizePerGCThread                   = 87241520                            {product}
    uintx InitialHeapSize                                := 130023424                          {product}
    uintx LargePageHeapSizeThreshold     = 134217728                           {product}
    uintx MaxHeapSize                                   := 2065694720                        {product}
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Can I use more Xmx then here (2065694720) ? 4G? 

вторник, 3 октября 2017 г., 12:15:07 UTC+3 пользователь seet...@gmail.com написал:

seet...@gmail.com

unread,
Oct 4, 2017, 4:22:45 AM10/4/17
to SonarQube
Since you just mentioned that you are using JDK 1.8, I am sure that you should not get this error but you should get a MetaspaceSize error as the Memory Management in JDK 1.8 is now Native Memory and not Heap Memory.

Nikita Gryzlov

unread,
Oct 4, 2017, 7:45:19 AM10/4/17
to SonarQube
We have OutOfMemory error at CE task at projects with >4 millions LOC. And passing more memory to -Xmx (6G in our case) solves the problem.

среда, 4 октября 2017 г., 11:22:45 UTC+3 пользователь seet...@gmail.com написал:

Nikita Gryzlov

unread,
Oct 4, 2017, 2:12:03 PM10/4/17
to SonarQube
Just in case - you need to change sonar.ce.javaOpts in your *server* config, not in sonar-project.properties at your repo.

вторник, 3 октября 2017 г., 8:23:42 UTC+3 пользователь Вадим Самойленко написал:
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Вадим Самойленко

unread,
Oct 6, 2017, 12:05:21 PM10/6/17
to SonarQube
I have set the ce.javaOpts -Xmx = 6G in SONAR_HOME/conf/sonar.properties. unsuccessful. I have set the ce.javaOpts -Xmx = 8G and my SonarQube was stoped with error "Cannot allocate memory" (((( 

среда, 4 октября 2017 г., 21:12:03 UTC+3 пользователь Nikita Gryzlov написал:

nixel2007

unread,
Oct 6, 2017, 12:27:13 PM10/6/17
to samoil...@gmail.com, sona...@googlegroups.com
Looks like you have not enough free memory in your server. Java can't allocate 8gb of ram if only 7gb is available (for example)



Отправлено с Mi Phone
Вадим Самойленко <samoil...@gmail.com> | От: 6 окт. 2017 г. 7:05 PM | Сообщение:
--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/-Zno0FBo8Jc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/ccca979e-24a1-450e-b77c-8743843d3483%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

nixel2007

unread,
Oct 6, 2017, 12:28:32 PM10/6/17
to samoil...@gmail.com, sona...@googlegroups.com
Also check the syntax of Xmx property. You should not add an "equal" sign



Отправлено с Mi Phone
Вадим Самойленко <samoil...@gmail.com> | От: 6 окт. 2017 г. 7:05 PM | Сообщение:

I have set the ce.javaOpts -Xmx = 6G in SONAR_HOME/conf/sonar.properties. unsuccessful. I have set the ce.javaOpts -Xmx = 8G and my SonarQube was stoped with error "Cannot allocate memory" (((( 

seet...@gmail.com

unread,
Oct 9, 2017, 1:14:52 AM10/9/17
to SonarQube
Hello all,

Nikita : JDK 1.8 is being used and not 1.7. The solution that you are referring here on XMX and XMS is for Heap Memory and not the Native Memory on which JDK 1.8 memory management is based on.

On my machine, I have altered the MetaspaceSize and it works just fine on a 256M configuration. It can be extended to 1/3rd of the total RAM on your machine and not more than this.

Hope this helps

epas...@vt.edu

unread,
Oct 12, 2017, 11:00:13 AM10/12/17
to SonarQube
Your sonar.search.javaOpts looks like you're trying to give it 2048G instead of M
Message has been deleted

Вадим Самойленко

unread,
Oct 19, 2017, 1:27:57 AM10/19/17
to SonarQube
The problem is gone.
I found poweful server with 64G RAM. And set 
sonar.ce.javaOpts=-Xmx64G
BUT faced with other problems:

Generate Quality profile events | time=2ms
2017.10.19 06:03:21 INFO  [o.s.s.c.s.ComputationStepExecutor] Generate Quality gate events | time=2ms
2017.10.19 06:03:24 INFO  [o.s.s.c.s.ComputationStepExecutor] Persist components | time=2669ms
2017.10.19 06:03:26 INFO  [o.s.s.c.s.ComputationStepExecutor] Persist snapshots | time=1429ms
2017.10.19 06:03:57 WARN  [o.a.i.e.BaseExecutor] Unexpected exception on closing transaction.  Cause: org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.IOException: Stream Closed"; "/home/esb99usr/SonarQubeHome/sonarqube-5.6.7/data/sonar.h2.db"; SQL statement:
ROLLBACK [90031-176]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.convertIOException(DbException.java:329)
at org.h2.store.FileStore.seek(FileStore.java:298)

May be I have to change type of the DataBase?? I use Embedded DB. 

In SONAR_HOME/logs/sonar.log I found:

2017.10.19 06:11:17 INFO   es[o.e.c.r.a.decider]  [sonar-1508377991376] low disk watermark [85%] exceeded on [xvfOS5ePT_Ct5bkoEYRWoA][sonar-1508377991376] free: 543.2mb[13.9%], replicas will not be assigned to this node
2017.10.19 06:11:31 ERROR web[o.s.s.w.WebServiceEngine] Fail to process request http://10.116.150.44:9000/api/ce/activity?status=IN_PROGRESS%2CSUCCESS%2CFAILED%2CCANCELED
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.IOException: Stream Closed"; "/home/esb99usr/SonarQubeHome/sonarqube-5.6.7/data/sonar.h2.db"; SQL statement:
select

I set other options like:

sonar.ce.javaOpts=-Xmx32G 
sonar.web.javaOpts=-Xmx32G 
sonar.search.javaOpts=-Xmx32G

and get:

2017.10.19 07:08:34 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AV8ylItTneC5kASvyPO6
org.sonar.server.computation.component.VisitException: Visit of Component {key=federal:appSrvUpdatePrivateTariff/ru/sbt/sbrf/esb/services/srvupdateprivatetariff/esql/ASFSVFL_to_mdo.esql,type=FILE} failed
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2017.10.19 07:08:34 ERROR ce[o.s.s.c.t.CeWorkerCallableImpl] Executed task | project=federal | type=REPORT | id=AV8ylItTneC5kASvyPO6 | submitter=admin | time=86461ms
2017.10.19 07:08:38 INFO   es[o.e.c.r.a.decider]  [sonar-1508385902758] low disk watermark [85%] exceeded on [i8rZxETxQuG2pa886VxqPA][sonar-1508385902758] free: 529.1mb[13.5%], replicas will not be assigned to this node

Full log file you can see in attachments
I tired to try put analyze report to sonar (((


вторник, 3 октября 2017 г., 8:23:42 UTC+3 пользователь Вадим Самойленко написал:
Hello! 
BackgroundTasksLog.txt
SonarLog.txt

jeanbaptist...@sonarsource.com

unread,
Oct 19, 2017, 5:24:03 AM10/19/17
to SonarQube
Hello,

Quoting from your message:

> ... Cause: org.h2.jdbc.JdbcSQLException ...

And:


> May be I have to change type of the DataBase?? I use Embedded DB.


Yes, definitely. Like told by the red footer message, the embedded H2 database is only intended for evaluation purpose. I would recommend something like Postgres for consistent performance on large-ish projects.

Cheers,
-- Jean-Baptiste Lievremont

Вадим Самойленко

unread,
Oct 22, 2017, 11:32:19 AM10/22/17
to SonarQube
Yes! Postgres is good. Now it works, Thanks  =)
One more question. 
RAM is busy for 16% but sonar analysis is done. SonarQube background tasks are done too. Why RAM cannot get back? screenshot in attachment 


четверг, 19 октября 2017 г., 12:24:03 UTC+3 пользователь jeanbaptist...@sonarsource.com написал:
Снимок.PNG

Duarte Meneses

unread,
Oct 23, 2017, 3:55:05 AM10/23/17
to SonarQube
Hi,

That's perfectly normal. Not only is the server still running and therefore using some memory, but the JVM doesn't garbage collect objects if it doesn't need to and also it keeps a pool of free heap memory depending on your jvm settings.


Duarte
Reply all
Reply to author
Forward
0 new messages