How to prevent java.lang.OutOfMemoryError: PermGen space at Scala compilation?

How to prevent java.lang.OutOfMemoryError: PermGen space at Scala compilation?

Asked on November 16, 2018 in Apache-spark.
Add Comment


  • 3 Answer(s)

     The explanation for OutOfMemoryError: PermGen space is that it does not have enough permanent generation space. When we areusing Oracle JVM, There will be a need to add the -XX:MaxPermSize=256M (or some other amount of space) argument to your sbt script. For other JVMs, look at their documentation.

    Answered on November 16, 2018.
    Add Comment

    Here the HomeBrew is used to install sbt on OS X. It supports a SBT_OPTS argument which can be put in ~/.sbtconfig file with export SBT_OPTS=-XX:MaxPermSize=256M.

    Answered on November 16, 2018.
    Add Comment

    When we are using sbt 0.13.6 or higher. The .sbtopts file is created in your sbt project’s root with the following content:

    -J-Xmx4G
    -J-XX:MaxMetaspaceSize=1G
    -J-XX:MaxPermSize=1G
    -J-XX:+CMSClassUnloadingEnabled
    

    Here the MaxMetaspaceSize is for Java 8 whereas MaxPermSize is for Java 7. They are critical to avoid out of memory errors related either to permgen or metaspace exhaustion. By assuming, adapting flag values or adding any other flags required.

     

    Answered on November 16, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.