Charlie Murray
Charlie Murray

Reputation: 11

Maven build using/allocating huge amount of memory

I have a decent sized GWT (Google Web Toolkit) project that is built using Apache Maven. The build process involves generating 8 rpms and 2 wars.

I'm trying to build the project on a remote virtual server, running CentOS 5.2 as a guest OS. Since the guest OS can't use swap space, I am having to allocate a huge amount of memory to the box for it to build, otherwise I get a java could not allocate memory error (error=12). The build fails if there is under 7GB free. I suspect that most of this 7GB is never used, but is allocated for some reason.

At the end of the build the output reads: [INFO] Final Memory: 178M/553M

I have MAVEN_OPTS set to -Xms256m -Xmx1024M

I'm not sure how to make the maven build use less memory. Any suggestions are much appreciated.

Upvotes: 1

Views: 3133

Answers (2)

krosenvold
krosenvold

Reputation: 77181

Note that forking plugins like the maven gwt plugin (and maven surefire) uses memory that is "outside" the total that is reported by the maven execution. I would recommend corrolating OS-level process sizes with the output from "jps -lv" to find out which fork is stealing all your memory.

If, for instance, for some reason the forked process does not terminate it would get very crowded, very quickly.

Upvotes: 4

Brett Porter
Brett Porter

Reputation: 5867

That memory indicates it only ever needed a max of 553M, so the setting in MAVEN_OPTS is already above what you need. Are you saying you want to use less than that, or are you currently getting an error?

Upvotes: 2

Related Questions