设置maven的最大堆大小
我正在将MacBook Pro与OSX Yosemite一起使用。当我在java项目下运行设置maven的最大堆大小,maven,jvm,maven-3,heap-memory,Maven,Jvm,Maven 3,Heap Memory,我正在将MacBook Pro与OSX Yosemite一起使用。当我在java项目下运行maven clean install时,我经常会遇到错误: java.lang.OutOfMemoryError: Java heap space 我在谷歌上搜索了一下,并按照建议添加环境变量,为maven设置更大的堆大小 我编辑了~/.bash_档案,添加了以下行: setenv MAVEN_OPTS "-Xmx1024M -XX:MaxPermSize=512m" 然后再次运行maven clea
maven clean install
时,我经常会遇到错误:
java.lang.OutOfMemoryError: Java heap space
我在谷歌上搜索了一下,并按照建议添加环境变量,为maven设置更大的堆大小
我编辑了~/.bash_档案,添加了以下行:
setenv MAVEN_OPTS "-Xmx1024M -XX:MaxPermSize=512m"
然后再次运行maven clean install
,但仍然得到OutOfMemoryError
。我如何设置maven使用最大1024M堆
==更新====
完整日志:
java.lang.OutOfMemoryError: Java heap space
at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.findCENRecord(ZipFileIndex.java:552)
at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.<init>(ZipFileIndex.java:497)
at com.sun.tools.javac.file.ZipFileIndex.checkIndex(ZipFileIndex.java:191)
at com.sun.tools.javac.file.ZipFileIndex.<init>(ZipFileIndex.java:137)
at com.sun.tools.javac.file.ZipFileIndexCache.getZipFileIndex(ZipFileIndexCache.java:100)
at com.sun.tools.javac.file.JavacFileManager.openArchive(JavacFileManager.java:559)
at com.sun.tools.javac.file.JavacFileManager.openArchive(JavacFileManager.java:482)
at com.sun.tools.javac.file.JavacFileManager.listContainer(JavacFileManager.java:368)
at com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:644)
at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2446)
at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2143)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:421)
at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:298)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:459)
at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:484)
at com.sun.tools.javac.comp.Enter.main(Enter.java:469)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:929)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:125)
at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:823)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
java.lang.OutOfMemoryError:java堆空间
位于com.sun.tools.javac.file.ZipFileIndex$zipddirectory.findCENRecord(ZipFileIndex.java:552)
位于com.sun.tools.javac.file.ZipFileIndex$ZipDirectory(ZipFileIndex.java:497)
位于com.sun.tools.javac.file.ZipFileIndex.checkIndex(ZipFileIndex.java:191)
位于com.sun.tools.javac.file.ZipFileIndex.(ZipFileIndex.java:137)
位于com.sun.tools.javac.file.ZipFileIndexCache.getZipFileIndex(ZipFileIndexCache.java:100)
位于com.sun.tools.javac.file.JavacFileManager.openArchive(JavacFileManager.java:559)
位于com.sun.tools.javac.file.JavacFileManager.openArchive(JavacFileManager.java:482)
位于com.sun.tools.javac.file.JavacFileManager.listContainer(JavacFileManager.java:368)
位于com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:644)
位于com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2446)
位于com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2143)
位于com.sun.tools.javac.code.Symbol.complete(Symbol.java:421)
在com.sun.tools.javac.comp.Enter.visitoplevel(Enter.java:298)
位于com.sun.tools.javac.tree.JCTree$jccomilationunit.accept(JCTree.java:459)
位于com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
位于com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
位于com.sun.tools.javac.comp.Enter.complete(Enter.java:484)
位于com.sun.tools.javac.comp.Enter.main(Enter.java:469)
位于com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:929)
位于com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
位于com.sun.tools.javac.main.main.compile(main.java:439)
位于com.sun.tools.javac.api.javactasquimpl.call(javactasquimpl.java:132)
位于org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:125)
位于org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
位于org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:823)
位于org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
位于org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
位于org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
位于org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
问题可能出在surefire插件运行的测试中。您应该在surefire
标签的
中包含选项,而不是MAVEN\u选项:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx1g -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
org.apache.maven.plugins
maven surefire插件
-Xmx1g-XX:MaxPermSize=256m
尽管这是一个非常古老的线程,但我认为值得补充的是,在使用maven编译器插件时可以使用以下配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<maxmem>512m</maxmem>
</configuration>
</plugin>
org.apache.maven.plugins
maven编译器插件
3.8.1
512m
谢谢,但我不认为我在使用surefire Plugin,你能分享更广泛的日志输出吗?您的应用程序中有任何测试吗?@Jakub Kubrynski,完整日志已添加。请检查我的更新。你能使用jmap-heap检查一下你的堆设置吗?我无法通过你建议的命令获得maven堆大小。但是我检查了我的java堆大小,InitialHeapSize=6815736,MaxHeapSize=35651584,PermSize=21757952,MaxPermSize=85983232