欢迎转载,转载请注明
http://blog.csdn.net/zengyangtech/article/details/7003379
今天,在编译一个大工程的时候遇到了问题
Unable to execute dex: Java heap space
上网找了一下,有两种解决方案:
1. eclipse.int 添加内存
2. 导入工程的jar通过 add User Library方式导入
右键工程->build path->add Library->user Library->user Libraries->new->随便取个名字->add JARs->ok
添加过程中记得将 user systemLibrary选中
eclipse.ini
下面直接可以配置相关参数
参数中-vmargs的意思是设置JVM参数,所以后面的其实都是JVM的参数了,我们首先了解一下JVM内存管理的机制,然后再解释每个参数代表的含义。
堆(Heap)和非堆(Non-heap)内存
按照官方的说法:“Java 虚拟机具有一个堆,堆是运行时数据区域,所有类实例和数组的内存均从此处分配。堆是在 Java 虚拟机启动时创建的。”“在JVM中堆之外的内存称为非堆内存(Non-heap memory)”。可以看出JVM主要管理两种类型的内存:堆和非堆。简单来说堆就是Java代码可及的内存,是留给开发人员使用的;非堆就是JVM留给自己用的,所以方法区、JVM内部处理或优化所需的内存(如JIT编译后的代码缓存)、每个类结构(如运行时常数池、字段和方法数据)以及方法和构造方法的代码都在非堆内存中。
堆内存分配
JVM初始分配的内存由-Xms指定,默认是物理内存的1/64;JVM最大分配的内存由-Xmx指定,默认是物理内存的1/4。默认空余堆内存小于40%时,JVM就会增大堆直到-Xmx的最大限制;空余堆内存大于70%时,JVM会减少堆直到-Xms的最小限制。因此服务器一般设置-Xms、-Xmx相等以避免在每次GC 后调整堆的大小。
非堆内存分配
JVM使用-XX:PermSize设置非堆内存初始值,默认是物理内存的1/64;由XX:MaxPermSize设置最大非堆内存的大小,默认是物理内存的1/4。
JVM内存限制(最大值)
首先JVM内存限制于实际的最大物理内存,假设物理内存无限大的话,JVM内存的最大值跟操作系统有很大的关系。简单的说就32位处理器虽然可控内存空间有4GB,但是具体的操作系统会给一个限制,这个限制一般是2GB-3GB(一般来说Windows系统下为1.5G-2G,Linux系统下为2G-3G),而64bit以上的处理器就不会有限制了。
参数形如“项 值”这种形式,中间有空格的需要换行书写,如果值中有空格的需要用双引号包括起来。比如我们使用-vm C:\Java\jre1.6.0\bin\javaw.exe参数设置虚拟机,在eclipse.ini文件中要写成这样:
-vm
C:\Java\jre1.6.0\bin\javaw.exe
其中–launcher.XXMaxPermSize(注意最前面是两个连接线)跟-XX:MaxPermSize参数的含义基本是一样的,区别就是前者是eclipse.exe启动的时候设置的参数,而后者是eclipse所使用的JVM中的参数。
分享到:
相关推荐
以下的问题是由于java的堆内存已满,需要java运行时加大java的堆内存空间 2019-10-09 18:02:32.858 [http-nio-8239-exec-6] ERROR c.a.b.c.exceptionHandler.CodeBaseExceptionHandler:69 - Handler dispatch failed...
thingsboard编译错误 Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.0:npm (npm install) on project js-executor: Failed to run task: 'npm install' failed. 该错误如果是3.0上的,请将...
spring-petclinic-master运行mvn install报错:Failed to execute goal io.spring.javaformat:spring-javaformat-maven-plugin:0.0.19:validate (default) on project spring-petclinic: Formatting violations ...
windows上eclipse运行hadoop程序报NullPointerException错 log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory). log4j:WARN Please initialize the log4j ...
java.lang.SecurityException: class "org.apache.commons.collections.SequencedHashMap"'s signer information does not match signer information of other classes in the same package at java.lang....
-bash: /usr/local/jdk/jdk1.8.0_181/bin/java: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory 安装完后 java -version 查看版本出现: 原因是:没有那个文件或目录,找了很久发现需要...
jetty-6.1.14(1).zip 共三部分,23.7m
idea创建Maven项目时,报错显示Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.0.2:resources,并且Maven插件内看不到 mybatis-generator。如下图: 折腾了好久发现配置放错地方了,...
y2ssh.sg.chp1.action.AddAction.execute(AddAction.java:18) y2ssh.sg.chp1.framework.Controller.doGet(Controller.java:25) y2ssh.sg.chp1.framework.Controller.doPost(Controller.java:33) javax.servlet....
android引入外部jar包弹出以下错误[2020-04-23 13:08:25 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/loopj/android/http/AsyncHttpClient$1; [2020-04-23 13:08:25 - Halloworld1] ...
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:420) at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:886) ... 11 more ERROR: Error fetching remote repo 'origin' ...
failed to execute script 解决方案+命令行执行传参exe
16 Steps to Develop and Implement a Software Quality Assurance Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Step 1. Document the Plan. . . ...
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:463) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405) ...
用于分包,解决 android 打包时报Unable to execute dex: method ID not in [0, 0xffff]: 65536
钉钉 Java SDK 钉钉官方提供了统一的SDK,使用SDK可以便捷的调用服务端API。注意:此SDK包含原有TOP接口,原有TOP接口可以继续正常调用,没有影响。下面是使用SDK调用API的请求示例: JAVA: DingTalkClient client...
破解Dev17.x的补丁,HOW TO USE: 0. Close all Visual Studio instanses. 1. Remove other patches at first (Previous versions of this patch will be uninstalled automatically using current version). 2. Run ...
主要介绍了Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1的解决办法的相关资料,需要的朋友可以参考下
myeclipse 2014 customize persperctive 无法 打开 修复 myeclipse 2014 customize persperctive 无法 打开 修复