[DESCRIPTION]
在编译core.jar或framework.jar很容易引起java OOM异常
错误信息
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
[KEYWORD]
out of memory
OOM
core.jar
framework.jar
signapk.jar
[SOLUTION]
原因:
1. Jar中塞了很多代码,消耗更多memory,可能导致heap溢出
2. 编译机器内存较小
解决方法:
修改build/core/definitions.mk里的transform-classes.jar-to-dex这function里的JXmx: 加大-JXmx1536M => 2048M (1024的倍数)
很多地方会有设置Xmx,如果遇到java OOM需要查看log看哪个地方溢出,然后在做调整
其他出现OOM的例子:
编译T卡升级包报错(./mk otapackage),提示内存不足
log如下:
building image from target_files RECOVERY...
running: mkbootfs /tmp/targetfiles-kRbwor/RECOVERY/RAMDISK
running: minigzip
running: mkbootimg --kernel /tmp/targetfiles-kRbwor/RECOVERY/kernel --ramdisk /tmp/targetfiles-kRbwor/RECOVERY/ramdisk --output /tmp/tmpxEiPed
running: imgdiff /tmp/tmpY36O6w /tmp/tmpxtUmXd /tmp/tmp11WNY3
[SEC OTA] Adding security version (WriteFullOTAPackage)
running: openssl pkcs8 -in build/target/product/security/testkey.pk8 -inform DER -nocrypt
running: java -Xmx2048m -jar out/host/linux-x86/framework/signapk.jar -w build/target/product/security/testkey.x509.pem build/target/product/security/testkey.pk8 /tmp/tmpvmjnCf out/target/product/ics2/htt77_ics2-ota-user.xxx.zip
ERROR: signapk.jar failed: return code 1
make[2]: *** [out/target/product/ics2/ics2-ota-user.xxx.zip] Error 1
分析:
此问题是运行signapk.jar导致内存不足,需要修改下参数:
在build/tools/releasetools/common.py里的SignFile函数中,加大-Xmx
cmd = ["java", "-Xmx512m", "-jar",
os.path.join(OPTIONS.search_path, "framework", "signapk.jar")]
修改为:
cmd = ["java", "-Xmx1024m", "-jar",
os.path.join(OPTIONS.search_path, "framework", "signapk.jar")]
在编译core.jar或framework.jar很容易引起java OOM异常
错误信息
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
[KEYWORD]
out of memory
OOM
core.jar
framework.jar
signapk.jar
[SOLUTION]
原因:
1. Jar中塞了很多代码,消耗更多memory,可能导致heap溢出
2. 编译机器内存较小
解决方法:
修改build/core/definitions.mk里的transform-classes.jar-to-dex这function里的JXmx: 加大-JXmx1536M => 2048M (1024的倍数)
很多地方会有设置Xmx,如果遇到java OOM需要查看log看哪个地方溢出,然后在做调整
其他出现OOM的例子:
编译T卡升级包报错(./mk otapackage),提示内存不足
log如下:
building image from target_files RECOVERY...
running: mkbootfs /tmp/targetfiles-kRbwor/RECOVERY/RAMDISK
running: minigzip
running: mkbootimg --kernel /tmp/targetfiles-kRbwor/RECOVERY/kernel --ramdisk /tmp/targetfiles-kRbwor/RECOVERY/ramdisk --output /tmp/tmpxEiPed
running: imgdiff /tmp/tmpY36O6w /tmp/tmpxtUmXd /tmp/tmp11WNY3
[SEC OTA] Adding security version (WriteFullOTAPackage)
running: openssl pkcs8 -in build/target/product/security/testkey.pk8 -inform DER -nocrypt
running: java -Xmx2048m -jar out/host/linux-x86/framework/signapk.jar -w build/target/product/security/testkey.x509.pem build/target/product/security/testkey.pk8 /tmp/tmpvmjnCf out/target/product/ics2/htt77_ics2-ota-user.xxx.zip
ERROR: signapk.jar failed: return code 1
make[2]: *** [out/target/product/ics2/ics2-ota-user.xxx.zip] Error 1
分析:
此问题是运行signapk.jar导致内存不足,需要修改下参数:
在build/tools/releasetools/common.py里的SignFile函数中,加大-Xmx
cmd = ["java", "-Xmx512m", "-jar",
os.path.join(OPTIONS.search_path, "framework", "signapk.jar")]
修改为:
cmd = ["java", "-Xmx1024m", "-jar",
os.path.join(OPTIONS.search_path, "framework", "signapk.jar")]