kapt An exception occurred: java.lang.OutOfMemoryError: GC overhead limit exceeded
Asked Answered
R

2

6

I am facing this issue where while building my code I am getting this exception. I have tried increasing the heap space in both build.gradle and Manifest file but none of them seems to be working. I have also changed the gradle properties but that hasn't worked as well.

What I think is issue according to me is that I am using databinding and room and somehow while generating files for same it happens to give this exception.

e: [kapt] An exception occurred: java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.google.googlejavaformat.Doc$State.withColumn(Doc.java:81)
at com.google.googlejavaformat.Doc$Token.computeBreaks(Doc.java:486)
at com.google.googlejavaformat.Doc$Level.computeSplit(Doc.java:330)
at com.google.googlejavaformat.Doc$Level.computeBreakAndSplit(Doc.java:320)
at com.google.googlejavaformat.Doc$Level.computeBroken(Doc.java:296)
at com.google.googlejavaformat.Doc$Level.computeBreaks(Doc.java:266)
at com.google.googlejavaformat.Doc$Level.computeSplit(Doc.java:330)
at com.google.googlejavaformat.Doc$Level.computeBreakAndSplit(Doc.java:320)
at com.google.googlejavaformat.Doc$Level.computeBroken(Doc.java:290)
at com.google.googlejavaformat.Doc$Level.computeBreaks(Doc.java:266)
at com.google.googlejavaformat.Doc$Level.computeSplit(Doc.java:330)
at com.google.googlejavaformat.Doc$Level.computeBreakAndSplit(Doc.java:320)
at com.google.googlejavaformat.Doc$Level.computeBroken(Doc.java:296)
at com.google.googlejavaformat.Doc$Level.computeBreaks(Doc.java:266)
at com.google.googlejavaformat.Doc$Level.computeSplit(Doc.java:330)
at com.google.googlejavaformat.Doc$Level.computeBreakAndSplit(Doc.java:320)
at com.google.googlejavaformat.Doc$Level.computeBroken(Doc.java:290)
at com.google.googlejavaformat.Doc$Level.computeBreaks(Doc.java:266)
at com.google.googlejavaformat.Doc$Level.computeSplit(Doc.java:330)
at com.google.googlejavaformat.Doc$Level.computeBreakAndSplit(Doc.java:320)
at com.google.googlejavaformat.Doc$Level.computeBroken(Doc.java:296)
at com.google.googlejavaformat.Doc$Level.computeBreaks(Doc.java:266)
at com.google.googlejavaformat.Doc$Level.computeSplit(Doc.java:330)
at com.google.googlejavaformat.Doc$Level.computeBreakAndSplit(Doc.java:320)
at com.google.googlejavaformat.Doc$Level.computeBroken(Doc.java:290)
at com.google.googlejavaformat.Doc$Level.computeBreaks(Doc.java:266)
at com.google.googlejavaformat.Doc$Level.computeSplit(Doc.java:330)
at com.google.googlejavaformat.Doc$Level.computeBreakAndSplit(Doc.java:320)
at com.google.googlejavaformat.Doc$Level.computeBroken(Doc.java:296)
at com.google.googlejavaformat.Doc$Level.computeBreaks(Doc.java:266)
at com.google.googlejavaformat.java.Formatter.format(Formatter.java:181)
at com.google.googlejavaformat.java.Formatter.getFormatReplacements(Formatter.java:245)



:app:kaptDebugKotlin FAILED

  FAILURE: Build failed with an exception.

  * What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> Compilation error. See log for more details

  * Try:
   Run with --stacktrace option to get the stack trace. Run with --info or - -debug option to get more log output. Run with --scan to get full insights.

  * Get more help at https://help.gradle.org

  BUILD FAILED in 5m 7s
Rejoin answered 4/10, 2018 at 7:40 Comment(2)
Can you please add exception in your question?Lamellibranch
please check with editable question.Rejoin
C
3

Following gradle settings worked for me.

-Xms256m -Xmx4096m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=225m -XX:+UseCompressedOops

This goes in your settings.gradle file as the value for the org.gradle.jvargs parameter, e.g.

org.gradle.jvmargs=-Xms2560m -Xmx4096m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=225m -XX:+UseCompressedOops

put line

org.gradle.jvmargs=-Xms2560m -Xmx4096m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=225m -XX:+UseCompressedOops

to your gradle.properties (Project Properties)

Cayenne answered 6/10, 2018 at 5:46 Comment(1)
So the jvargs setting should be put in settings.gradle and in grale.properties as well??Bert
V
0

Another method to set the heap size for particular jobs is to use environment variables for each job. This ensures that the memory is available when the job that requires a higher memory is not in use.

GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xms1024M -Xmx8192M -XX:PermSize=512M -XX:MaxPermSize=2048 -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"

JAVA_OPTS="-XX:MaxPermSize=2048M"

Jenkins job config

Vyborg answered 15/4, 2020 at 6:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.