相关疑难解决方法(0)

Android Studio - 如何增加分配的堆大小

我已经使用Android Studio 3个月了,我开始使用的其中一个应用程序变得相当大.程序右下方显示的内存使用情况表明我分配的堆最大值为494M.

在此输入图像描述

当我开始更改XML文件时,我的内存使用量很快达到上限,并且IDE崩溃时出现Out Of Memory错误.

在此输入图像描述

我试图用这个增加堆大小,但到目前为止没有任何影响.

我已经看了几十篇关于如何增加堆大小的文章和其他问题,但他们的答案都没有奏效.无论我对VMOPTIONS或IDE设置做什么,堆大小都不会增加.我相信我正在为VMOPTIONS编辑正确的文件,因为如果我故意给它一个无效的命令Android Studio抱怨它并且不启动.

我正在使用Windows 7 - 64位并拥有16GB RAM.Android Studio有没有其他人遇到此问题?你能解决它吗?

crash android memory-management out-of-memory android-studio

111
推荐指数
14
解决办法
18万
查看次数

Android Studio:超出了GC开销限制

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> java.lang.OutOfMemoryError: GC overhead limit exceeded
Run Code Online (Sandbox Code Playgroud)

尝试:

dexOptions {
    javaMaxHeapSize "4g"
}
Run Code Online (Sandbox Code Playgroud)

这似乎是在线提供的唯一解决方案.

但它仍然超过了第二次构建的限制,除非我杀死工作室任务并重新启动,这使它第一次工作.

build.gradle中的依赖项肯定不多

build.grade

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.xxxxx.android"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 8
        versionName "1.3"
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.squareup.okhttp:okhttp:2.3.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.3.0'
    compile …
Run Code Online (Sandbox Code Playgroud)

android android-studio

8
推荐指数
2
解决办法
8201
查看次数