【问题标题】:java virtual machine Crashingjava虚拟机崩溃
【发布时间】:2013-06-13 14:08:04
【问题描述】:

我编写了一个 Java Spring-WS-Application 服务器并尝试使用 maven 从命令行部署它。但是,当尝试执行“mvn clean package”时,它告诉我由于堆空间不足而无法创建 Java 虚拟机。我的电脑只有 4GB 的 RAM,而且运行的是 32 位 Windows。只要我包含 -DskipTests,部署就会成功。

这个项目依赖于我的团队编写的其他项目,我可以使用“mvn clean install”毫无问题地部署它们。我也可以毫无问题地部署其他服务器,所以我认为我的 java 版本没有损坏。此外,我的开发团队的其他成员已经能够在他们的机器上成功部署此服务器。

我还检查并注释掉了所有 @Test 注释以尝试查找错误测试,但是当没有要运行的测试时它仍然给我这个错误。

对于为什么会发生这种情况有什么想法吗?

Java 版本:

java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode, sharing)

“mvn clean package:”的结果

   C:\workspace\My-Project>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building My Project Spring-WS Application 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ my-project ---
[INFO] Deleting C:\workspace\My-Project\target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ my-project ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\workspace\My-Project\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ my-project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 49 source files to C:\workspace\My-Project\target\classes
[WARNING] Note: C:\workspace\My-Project\src\main\java\my\package\of\doom\impl\classImpl.java uses or overrides a 
deprecated API.
[WARNING] Note: Recompile with -Xlint:deprecation for details.
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ my-project ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ my-project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 25 source files to C:\workspace\My-Project\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.14:test (default-test) @ my-project ---
[INFO] Surefire report directory: C:\workspace\My-Project\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Error occurred during initialization of VM
Could not create the Java virtual machine.
Could not reserve enough space for object heap

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.783s
[INFO] Finished at: Thu Jun 13 09:01:15 EDT 2013
[INFO] Final Memory: 14M/54M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project my-pro
ject: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test failed: The fo
rked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command wascmd.exe /X /C "C:\Oracle2\Middleware\jdk160_24\jre\bin\java -Xms512m -Xmx1024m -XX:MaxPermSize=512m -
jar C:\workspace\My-Project\target\surefire\surefirebooter4008500116671254841.jar C:\workspace\My-Project\target\surefir
e\surefire8598565507069545685tmp C:\workspace\My-Project\target\surefire\surefire_07977292658698847040tmp"
[ERROR] ->     [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR]     [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Eclipse.ini:

-vm
C:/Oracle2/Middleware/jdk160_24/bin/javaw
-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
-vmargs
-Xms512m
-Xmx1024m
-XX:MaxPermSize=512m
-Dsun.lang.ClassLoader.allowArraySyntax=true

【问题讨论】:

  • 最大烫发尺寸 512m?哎哟。有没有试过增加-Xmx参数值?
  • 如果你有足够的内存,增加 Xms、Xmx 和 MaxPermSize。您是否检查过服务器需要多少内存?

标签: java spring maven maven-surefire-plugin


【解决方案1】:

仔细查看错误消息。它说没有足够的内存用于测试 JVM 的堆。尝试释放一些内存(关闭 Eclipse)和/或使用较低的堆/永久生成大小运行测试(确保设置)。

【讨论】:

  • 我在安全设置中找到了 -Xms512m -Xmx1024m -XX:MaxPermSize=512m 行,删除该行或将 MaxPermSize 更改为 256m 似乎可以解决我的问题。谢谢!出于好奇,您知道为什么减小 Permgen 大小可以解决此问题吗?
  • Permgen 空间也是从内存中保留的,因此大的 perm gen 空间会占用堆所需的空间。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-12-07
  • 1970-01-01
  • 2023-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多