This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven Memory Planning and Usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven Memory Planning and Usage" Watch "Maven Memory Planning and Usage" New topic

Maven Memory Planning and Usage

Gaurav Upadhyay

Joined: Oct 11, 2012
Posts: 10
I am looking for some information or documentation on the use of memory by Maven. Does it grow with the size of your ear/war/jars, number of java files compiled, plugins used etc. And how? What is the pattern?

So our maven builds would tell us via the logs :

Total time: XXXMM:SS:MSSS
Finished at: XXXDATE
Final Memory: 24M/58M

So, above, 58M max was to be utilized by default unless MAVEN_OPTS are set to a different value.

But how do we do capacity planning with Maven in terms of the hardware's memory which will be used for the builds to run? How much memory would Maven take given you know the number of ears/java files/plugins used etc ? Is there any empirical way to derive it?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

I don't know how to derive it. Once piece of advice:
We've seen our Maven memory spike due to very large JUnit tests that use Spring. Spring contexts are huge and if you create them multliple times.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Gaurav Upadhyay

Joined: Oct 11, 2012
Posts: 10
So there is no known way to analyse and prepare for how Maven would use the memory?
Peter Johnson

Joined: May 14, 2008
Posts: 5852

No there isn't, that I know of. One of our builds causes an OOME with the default memory settings (which we run into each time someone sets up a new dev or build machine), so we set the max heap to 1024M. But the thing is, once you know what is needed for a build, there is rarely any need to change it - the memory requirements for a build will not change all that much unless you are adding dozens of classes to your app each day.

JBoss In Action
Jayesh A Lalwani
Saloon Keeper

Joined: Jan 17, 2008
Posts: 2748

We have a huge multi module project, and we are just about finishing up mavenizing the whole build. We have lots and lots integeration tests. QA adds like a 1000 cases every 3 months, and over the past 5 years, we easily have 10K+ integeration tests. We do run OOM even after setting max memory to 1G. What we ended up doing (actually haven't done it yet) is divide up the test cases by test scenarios, and group related test scenarios under a profile. We use team city as our CI server, and team city has these feature where you can have several agents running under team city. We have setup a TC build for every profile, and on a daily basis our agents wake up and start running the TC builds. The advantage here is that integeration tests all run in parallel, and also we limit the amount of memory required by each build. Oh yeah, we have the unit testing on the grid

I don;t know of anyway of sizing your Maven build. That's almost like asking "how do you know how much memory to give to Eclipse?". Most people do it empirically; ie; keep using it till it runs out of memory, then complain till someone gives you more memory

If you have a really large project, Maven does provide strategies that can be used to limit the scope of your build. If you have a large team of like 50 developers and 70 QA who are constantly checking in code, you are obviously not going to have everyone build your entire repo everytime. You will probably have to come up with a way so that developers build their own piece. The CI server will need to be sized empirically, and if you are really big, you will have to start thinking about multiple CI servers
I agree. Here's the link:
subject: Maven Memory Planning and Usage
It's not a secret anymore!