How to solve java.lang.OutOfMemoryError: GC overhead limit exceeded error in android studio

后端 未结 7 935
执笔经年
执笔经年 2021-01-31 02:53

I am using android studio 1.0 RC for 64 bit linux.

When I run my application I am getting

\"java.lang.OutOfMemoryError: GC overhead limit          


        
7条回答
  •  被撕碎了的回忆
    2021-01-31 03:31

    Add this to your "gradle.properties" file:

    org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
    

    Also, read this article. You might be able to make the building a bit faster, by adding a combination of those:

    org.gradle.daemon=true
    org.gradle.parallel=true
    org.gradle.configureondemand=true
    

    EDIT: an updated answer based on my experience:

    On Android Studio, choose Help -> Edit custom VM options , and then set the max memory the IDE is allowed to use. For example, if you want 5GB, use this:

    -Xmx5g
    

    Save the file, close all windows of the IDE (make sure it has no processes) and then restart the IDE.


    EDIT: Android Studio now has RAM configuration in its settings. Go to "help"->"change memory settings".

提交回复
热议问题