去杠杆化18.5 MB“;android-4.1.1“uR1.jar”;给予;java.lang.OutOfMemoryError:java堆空间;
我正在尝试启动OSGI框架,并在Android上启动一些捆绑包。其中一个捆绑包是android API捆绑包,它是一个18.5 MB的jar。我读到,为了在android上启动捆绑包,所有捆绑包都应该首先进行索引化 因此,我尝试使用以下命令对“android-4.1.1_r1.jar”进行索引化:去杠杆化18.5 MB“;android-4.1.1“uR1.jar”;给予;java.lang.OutOfMemoryError:java堆空间;,java,android,heap,bundle,dex,Java,Android,Heap,Bundle,Dex,我正在尝试启动OSGI框架,并在Android上启动一些捆绑包。其中一个捆绑包是android API捆绑包,它是一个18.5 MB的jar。我读到,为了在android上启动捆绑包,所有捆绑包都应该首先进行索引化 因此,我尝试使用以下命令对“android-4.1.1_r1.jar”进行索引化: dx --dex --output=classes.dex C:\Users\student\Documents\eclipse\myPlugins\plugins\android-4.1.1_r1.
dx --dex --output=classes.dex C:\Users\student\Documents\eclipse\myPlugins\plugins\android-4.1.1_r1.jar
但我在命令行中遇到了以下错误:
java.lang.OutOfMemoryError: Java heap space
第一:我真的需要对这个文件进行索引吗?
第二:如果我必须对其进行索引化,那么如何才能消除上述错误
要增加我的堆大小
我试过:java-Xmx4g
,但我得到了
Invalid maximum heap size: -Xmx4g
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
然后我尝试了java-Xmx2g
,但是我得到了
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
所以我尝试了java-Xmx1g
,然后java-Xmx1100g
得到了:
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m
ore details.
用法:java[-options]类[args…]
(执行一个类)
或java[-options]-jar jarfile[args…]
(执行jar文件)
其中包括:
-d32使用32位数据模型(如果可用)
-d64使用64位数据模型(如果可用)
-客户端选择“客户端”虚拟机
-选择“服务器”虚拟机的服务器
-hotspot是“客户端”VM的同义词[已弃用]
默认VM是客户端。
-cp
-类路径
A.单独的目录列表、JAR归档、,
和压缩档案以搜索类文件。
-D=
设置系统属性
-详细[:类| gc | jni]
启用详细输出
-版本打印产品版本并退出
-版本:
需要指定的版本才能运行
-showversion打印产品版本并继续
-jre限制搜索|-无jre限制搜索
在版本搜索中包括/排除用户专用JRE
-? -帮助打印此帮助消息
-关于非标准选项的X打印帮助
-ea[:…|:]
-启用评估[:…|:]
启用具有指定粒度的断言
-da[:…;:]
-取消分配[:…|:]
禁用具有指定粒度的断言
-esa |-启用系统断言
启用系统断言
-dsa |-禁用系统断言
禁用系统断言
-agentlib:[=]
加载本机代理库,例如-agentlib:hprof
另请参见-agentlib:jdwp=help和-agentlib:hprof=help
-代理路径:[=]
按完整路径名加载本机代理库
-javaagent:[=]
加载Java编程语言代理,请参阅Java.lang.instrument
-飞溅:
用指定的图像显示启动屏幕
看见http://www.oracle.com/technetwork/java/javase/documentation/index.html 为了m
矿石细节。
在所有情况下,当我尝试对bundle文件进行索引时,仍然会出现相同的错误。我该怎么办?我使用的是安装了4.00 GB的Windows 32位(可用2.96 GB)。最大堆大小由许多因素决定,包括:
- 无论您运行的是32位还是64位JVM
- 无论您是在32位还是64位操作系统上运行
- 您正在使用的操作系统/版本
- 你有多少物理内存
- 系统是否为分页分配了足够的磁盘空间
- Java应用程序需要多少非堆内存
-Xmx1g
应该可以工作。。。除非你同时有很多其他的事情要做
你是说我在上面展示的东西有效吗 没有 我是说,它本该起作用的。事实上,你得到了一个“用法”信息是令人费解的。我认为这意味着命令行还有其他问题。(你忘了告诉
java
运行什么类了吗?)
我所说的推论是,如果您关闭各种其他应用程序(如IDE、web浏览器、电子邮件客户端)以释放内存和/或分页文件空间,它可能会起作用。(如果页面文件碎片严重,重新启动也可能有帮助。)
如果这没有帮助,那么:
- 您可以尝试将JAR文件拆分为更小的JAR文件
- 你可以在更大的机器上做索引
- 你可以安装Linux。。。这将允许您在同一硬件上创建更大的Java堆