GeeCON Prague 2014*
The moose likes Ant, Maven and Other Build Tools and the fly likes maven -- java.lang.OutOfMemoryError: Java heap space Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "maven -- java.lang.OutOfMemoryError: Java heap space" Watch "maven -- java.lang.OutOfMemoryError: Java heap space" New topic
Author

maven -- java.lang.OutOfMemoryError: Java heap space

Sudhana Madhu
Greenhorn

Joined: Aug 20, 2007
Posts: 8
Hi,
I am using maven to run my test cases .test cases are mostly related to I/O operation.I am frequently running out of heap space .
how can I set -Xms256m -Xmx1024m for maven?
thanks in advance.
Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
did you use the eclipse maven plugin to do maven build ? I used to get the same when i used eclipse maven plugin.... but outside eclipse, it was fine...
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Assume you are running from the command line, Maven is run via the mvn (or mvn.bat) script in m2_home/bin. You edit that file, modifying the Java run command. Or you can add a MAVEN_OPTS=xxx line early in that file. Or you could even set the MAVEN_OPTS env var before running maven.


JBoss In Action
Sudhana Madhu
Greenhorn

Joined: Aug 20, 2007
Posts: 8
I have set env variable before running maven
but that couldn't solve the problem.
below is the stack trace .
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

How big is your physical memory? You shouldn't use -Xmx greater or equal to your physical memory.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Sudhana Madhu
Greenhorn

Joined: Aug 20, 2007
Posts: 8

my total memory is 2020 mb so I can use 1024m for MAVEN_OPTS=-Xmx1024M
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

You might try "export MAVEN_OPTS=-Xmx1024m".

Also, set _JAVA_LOADER_DEBUG (you can set it to anything). This will cause the JVM to dump some startup information, including the JVM options it was given. This should help determine if the heap size is being set.
Sudhana Madhu
Greenhorn

Joined: Aug 20, 2007
Posts: 8
thanks for your help
its working after setting MAVEN_OPTS env variable to 1024m
 
GeeCON Prague 2014
 
subject: maven -- java.lang.OutOfMemoryError: Java heap space