Search code examples
scalaconfigurationgarbage-collectionsbt

On scala project - Getting error GC overhead limit exceeded when running sbt test command


I'm new in scala programming and getting GC overhead limit exceeded error when I execute sbt test command in one of big scala project. Anyone knows how can I solve this?


Solution

  • I got help from my friends :)

    Increase the memory option by executing with -mem option for example:

    sbt -mem 2048 test

    Other options:

    For Mac & Linux user:

    if we need to execute this a lot. We can update the .bash_profile file and add below command:

    export SBT_OPTS="-Xmx2G"

    Other solution (works with Windows as well):

    There's also a specific sbtopts file where you can persist this memory setting:

    Find a file in Mac/Linux: /usr/local/etc/sbtopts Or in Windows C:\Program Files (x86)\sbt\conf

    and add below configuration:

    # set memory options
    #
    -mem   2048
    

    Hopefully any of these tips will help someone with this problem.

    EDIT:

    If anyone using IntelliJ IDEA like me, you can increase the sbt memory usage using the VM Parameters as in the picture below.

    -Xmx4G
    

    enter image description here