0

I set MAVEN_OPTS -Xms4096m and -Xmx4096m to prevent my rather large program from running out of memory, but it still runs into "OutOfMemoryError: Java heap space"! I'm trying to run it with more memory, but the weird thing is that the build failure message also shows "Final Memory: 198M/3925M", implying that the program only used 198M even though I set the maximum much higher than that!

Does anybody know what is going on here?

EDIT: Here is the error message.

[WARNING] 
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.OutOfMemoryError: Java heap space
at cc.mallet.types.SparseVector.<init>(SparseVector.java:84)
at cc.mallet.types.SparseVector.<init>(SparseVector.java:101)
at cc.mallet.types.SparseVector.<init>(SparseVector.java:104)
at cc.mallet.types.FeatureVector.<init>(FeatureVector.java:75)
at MaxEntClassification.addToInstanceList(MaxEntClassification.java:127)
at MaxEntClassification.addToInstanceList(MaxEntClassification.java:100)
at runClassifierOnTweets.main(runClassifierOnTweets.java:101)
... 6 more
[INFO]     ------------------------------------------------------------------------  
[INFO] BUILD FAILURE  
[INFO] ------------------------------------------------------------------------  
[INFO] Total time: 01:38 h  
[INFO] Finished at: 2016-08-14T03:29:07-04:00  
[INFO] Final Memory: 199M/7173M  
[INFO]     ------------------------------------------------------------------------  
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project FluTweetsFeatureExtraction: An exception occured while executing the Java class. null: InvocationTargetException: Java heap space -> [Help 1]  
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project FluTweetsFeatureExtraction: An exception occured while executing the Java class. null  
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. null
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:345)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
trincot
  • 317,000
  • 35
  • 244
  • 286
  • 1
    Check the answer to this question - maybe it can help you http://stackoverflow.com/questions/4066424/java-lang-outofmemoryerror-java-heap-space-in-maven – lenach87 Aug 13 '16 at 20:59
  • 1
    can we see the maven output, my guess is that it's not a maven OOM but some plugin OOM (wild guess: surefire) –  Aug 13 '16 at 21:13
  • 2
    You've ran your jvm with 4096 bytes = 4kB heap size - that's way too low. Try `-Xms4096M -Xmx4096M` – Janez Kuhar Aug 13 '16 at 21:32
  • @JanezKuhar Sorry that was a typo. I actually did have it as -Xmx4096m – jumboqwomqwom Aug 14 '16 at 06:13
  • @RC I added the error message. Thanks in advance. – jumboqwomqwom Aug 14 '16 at 17:11
  • Can we see `runClassifierOnTweets.java`, maybe you have some kind of infinite loop, AFAIK exec:java doesn't fork a process, so it's maven memory settings that are used. –  Aug 14 '16 at 17:58
  • @RC there's no infinite loop; the program works just fine on a smaller input file. The program does create a very, very large array, but if the program is actually running out of memory, why does it tell me that the final memory used is only 198M? – jumboqwomqwom Aug 14 '16 at 20:02
  • When Maven reports the final memory, a gc might have collected the memory allocated by your code (with exec-maven-plugin:java). Try to execute your code outside of Maven and provide a heap dump. – benbenw Sep 04 '16 at 11:31
  • @benbenw So that's why it only reported using 200MB? Thanks. Yeah, as it turned out, my program needed a lot more than 4 gigs to run. – jumboqwomqwom Sep 05 '16 at 18:05

0 Answers0