File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Performance and the fly likes JVM Max Heap Size recommended Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "JVM Max Heap Size recommended" Watch "JVM Max Heap Size recommended" New topic

JVM Max Heap Size recommended

Neelesh A Korade

Joined: Jun 07, 2007
Posts: 26
Hi All,

We have a J2EE application being deployed in the production environment on SAP's NetWeaver application server. The server machine on which the application is being deployed has 16GB RAM, with no other major application running on the same server. Even the NetWeaver application server is going to host our application alone.

We are trying to figure out what would be an ideal value for JVM max heap size for the application server. If we can have JVM max heap size in the range of 4 to 8 GB, we can enable multi threading in our application to process transactional data in parallel. But I came across a reference in one of the articles which said for max heap size beyond 2GB, the applications starts experiencing garbage collection pauses, as the garbage collector runs take much longer to complete.

Can anybody provide us with any inputs on this? Particularly, what's the maximum JVM heap size one can have, without having to suffer from any such issues as garbage collection pauses?

Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
I don't have experience of using such large heaps, but it would seem a shame to constrain your application to use much less than the machine has available.

There are lots of different garbage collector configuration parameters available. There are a number of different garbage collectors available, and each one has settings to twiddle They let you trade off things total amount of GC time versus maximum pause time etc. I'd imagine that somewhere in the space of settings is one that would suit your application.

I suggest careful consultation of the documentation of your JVM's GC settings, and some experimentation.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Stephen King

Joined: Jul 08, 2007
Posts: 23

If you are using a 32 bit JVM, what you have read (max heap size ~ 2GB) is correct. It won't allow you to configure any higher value for heap. However, that is not the only parameter which can be tuned.

If you switch on the VERBOSEGC, and find that the number of minor garbage collections are higher than the major ones, adjusting the new to old generation ratio (to provide more space to the new generation objects) would bring down the frequency of garbage collections in the JVM.

I hope you are using Hotspot JVM, aren't you?


Believe in yourself!
Henry Wong

Joined: Sep 28, 2004
Posts: 20517

Configuring and tuning the Sun garbage collector can actually get complicated -- and quite frankly doesn't always work. (meaning there are tradeoffs)


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Neelesh A Korade

Joined: Jun 07, 2007
Posts: 26
Thanks for all the inputs everyone. That really helps. Just to clarify a few queries made in the responses-

We are using a 64bit JVM. And the JVM is a Hotspot one.

I will look at the Hotspot GC documentation. Thanks for all the help.

Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112|outline looks interesting

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link:
subject: JVM Max Heap Size recommended
jQuery in Action, 3rd edition