增加堆大小后无法启动Glassfish

时间:2011-10-12 08:22:04

标签: jvm glassfish heap-size

我想增加Glassfish的堆大小。为此,我知道我可以达到4GB:

java -Xmx4000M -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3425)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)

我尝试在domain.xml文件中将-Xmx设置为2GB:

<jvm-options>-Xmx2000m</jvm-options>

但是我收到以下错误:

asadmin> start-domain
Waiting for ... to start .Error starting domain ...
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

Error occurred during initialization of VM
The size of the object heap + VM data exceeds the maximum representable size
launchctl bsexec failed: Inappropriate ioctl for device

使用-v选项启动命令可以得到:

12 oct. 2011 11:46:34 com.sun.enterprise.admin.launcher.GFLauncherLogger info
INFO: JVM invocation command line:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java
-XX:+UnlockDiagnosticVMOptions
-XX:MaxPermSize=512m
-XX:NewRatio=2
-XX:+CMSClassUnloadingEnabled
-Xmx2000m
-Xms1000m
...
12 oct. 2011 11:46:35 com.sun.enterprise.admin.launcher.GFLauncherLogger info
INFO: Successfully launched in 45 msec.
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
Command start-domain failed.

3 个答案:

答案 0 :(得分:12)

我发现了问题。由于某些我不理解的原因,在命令中传递了“-d32”参数,要求以32位模式启动。添加时

<jvm-options>-d64</jvm-options>

到domain.xml文件,glassfish启动。请注意,该选项在文件中默认不存在。

答案 1 :(得分:0)

在执行“-version”时和GlassFish中必须使用不同的Java安装。我可以在Mac OS的路径中使用默认的“java”重现相同的错误,但在使用绝对路径时则不能:

% /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -Xmx2300m -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-383-11A511)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-383, mixed mode)
% java -Xmx2300m -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

答案 2 :(得分:0)

您的系统上是否有足够的磁盘空间?保留4GB的RAM可能需要MAC OS来扩展交换空间,并且您可能没有磁盘空间来执行此操作。不幸的是,这之前让我感到烦恼: - /