Insufficient memory for Java Virtual Machine heap during Android Compilation

Source: Internet
Author: User
Tags gc overhead limit exceeded
Ubuntu 12.04 server (64-bit) Android compilation encounters the Java Virtual Machine heap memory insufficiency problem unexpected top-level error: Java. lang. outofmemoryerror: GC overhead limit exceeded at com. android. DX. dex. code. outputfinisher. findexpandedopcodeforinsn (outputfinisher. java: 525) at com. android. DX. dex. code. outputfinisher. calculatereservedcount (outputfinisher. java: 466) at com. android. DX. dex. code. outputfinisher. reserveregisters (outputfinisher. java: 402) at com. android. DX. dex. code. outputfinisher. finishprocessingandgetlist (outputfinisher. java: 358) at com. android. DX. dex. code. dalvcode. finishprocessingifnecessary (dalvcode. java: 108) at com. android. DX. dex. code. dalvcode. getinsns (dalvcode. java: 185) at com. android. DX. dex. file. codeitem. place0 (codeitem. java: 223) at com. android. DX. dex. file. offsetteditem. place (offsetteditem. java: 242) at com. android. DX. dex. file. mixeditemsection. placeitems (mixeditemsection. java: 312) at com. android. DX. dex. file. dexfile. todex0 (dexfile. java: 543) at com. android. DX. dex. file. dexfile. todex (dexfile. java: 216) at com. android. DX. command. dexer. main. writedex (main. java: 574) at com. android. DX. command. dexer. main. run (main. java: 218) at com. android. DX. command. dexer. main. main (main. java: 174) at com. android. DX. command. main. main (main. java: 95) Make: *** [out/target/common/obj/java_libraries/framework_intermediates/noproguard. A classes-with-local.dex] Error 3

 

 

Solution:

Method 1:

Use Java commands to specify the size of the Java Virtual Machine heap to compile the required items first. It may take several minutes.

 

Java-xms3550m-xmx3550m-Jar/home/test/4.0/out/host/linux-x86/framework/dx. jar -- Dex -- output = out/target/common/obj/java_libraries/framework_intermediates/noproguard. classes-with-local.dex -- Core-library out/target/common/obj/java_libraries/framework_intermediates/noproguard. classes. jar

After running this command. Make again. Because the package has been made, it will not be compiled again when you make it again.

This method can only be executed after the make command fails, and then the make command is executed later.

 

Method 2:

Modify the definitions. mk file. This file is located in the build/CORE/directory.

Variable:-jxms16m-jxmx1024m value in the transform-classes.jar-to-dex

Variable definition in the Code:

Define transform-classes.jar-to-dex
@ Echo "target DEX: $ (private_module )"
@ Mkdir-p $ (DIR $ @)
$ (Hide) $ (dx )\
$ (If $ (findstring windows, $ (host_ OS),-jxms16m-jxmx1024m )\
-- Dex -- output =$ @\
$ (If $ (no_optimize_dx ),\
-- No-optimize )\
$ (If $ (generate_dex_debug ),\
-- Debug -- verbose \
-- Dump-To = $ (@:. DEX =. lst )\
-- Dump-width = 1000 )\
$ (Private_dx_flags )\
$ <
Endef

Change-jxms16m-jxmx1024m to an appropriate value.

My machine is 32 GB in memory, and I changed-jxms16m-jxmx1024m to-jxms1024m-jxmx2048m

The size of the specific value depends on the memory of the specific machine. If the value of memory is too small, the problem may occur.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.