当我执行JUnit测试时,我得到了这个错误消息:
java.lang.OutOfMemoryError: GC overhead limit exceeded
我知道什么是OutOfMemoryError,但是GC开销限制意味着什么?我怎么解决这个问题?
当我执行JUnit测试时,我得到了这个错误消息:
java.lang.OutOfMemoryError: GC overhead limit exceeded
我知道什么是OutOfMemoryError,但是GC开销限制意味着什么?我怎么解决这个问题?
当前回答
我在使用Oracle web逻辑服务器时得到了这个错误。我分享我的答案作为参考,以防有人最终在这里寻找解决方案。
所以,如果你试图提升Oracle web逻辑服务器并得到这个错误,那么你只需要增加运行服务器的初始和最大堆大小。
转到- > C:\Oracle\Middleware\Oracle_Home\user_projects\domains\wl_server\bin 打开setDomainEnv.cmd 检查设置USER_MEM_ARGS值,如果小于 set USER_MEM_ARGS="- xms128m - Xmx8192m ${MEM_DEV_ARGS} ${MEM_MAX_PERM_SIZE}"
这意味着初始堆大小设置为128 MB,最大堆大小为8GB。 现在,只需保存文件并重新启动服务器。如果不能解决问题,请尝试增加大小或寻找优化服务的方法。
参考,检查这个链接:https://docs.oracle.com/cd/E49933_01/server.770/es_install/src/tins_postinstall_jvm_heap.html
edit:检查您是否能够在运行服务器时看到更新的java参数。就像这样 如果它像以前一样,那么替换setDoaminEnv中显示的值。CMD由简单的搜索和替换。
其他回答
重启MacBook帮我解决了这个问题。
如果您确定程序中没有内存泄漏,请尝试:
增加堆的大小,例如-Xmx1g。 启用并发低暂停收集器-XX:+UseConcMarkSweepGC。 在可能的情况下重用现有对象以节省内存。
如果需要,可以通过在命令行中添加-XX:-UseGCOverheadLimit选项来禁用限制检查。
I'm working in Android Studio and encountered this error when trying to generate a signed APK for release. I was able to build and test a debug APK with no problem, but as soon as I wanted to build a release APK, the build process would run for minutes on end and then finally terminate with the "Error java.lang.OutOfMemoryError: GC overhead limit exceeded". I increased the heap sizes for both the VM and the Android DEX compiler, but the problem persisted. Finally, after many hours and mugs of coffee it turned out that the problem was in my app-level 'build.gradle' file - I had the 'minifyEnabled' parameter for the release build type set to 'false', consequently running Proguard stuffs on code that hasn't been through the code-shrinking' process (see https://developer.android.com/studio/build/shrink-code.html). I changed the 'minifyEnabled' parameter to 'true' and the release build executed like a dream :)
简而言之,我必须改变应用程序级别的“构建”。Gradle文件来自: / /……
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.sign_config_release
}
debug {
debuggable true
signingConfig signingConfigs.sign_config_debug
}
}
//...
to
//...
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.sign_config_release
}
debug {
debuggable true
signingConfig signingConfigs.sign_config_debug
}
}
//...
下面的方法对我很有效。只需添加以下片段:
android {
compileSdkVersion 25
buildToolsVersion '25.0.1'
defaultConfig {
applicationId "yourpackage"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
}
在Netbeans中,设计最大堆大小可能会有所帮助。执行命令Run =>设置项目配置=>自定义。在弹出窗口的运行中,进入虚拟机选项,填写-Xms2048m -Xmx2048m。它可以解决堆大小的问题。