What are the necessary steps in getting a optimized value of Xms/Xmx/XX:MaxPermSize
?
Definitely I can set a large value but as you know GC take time in large memory. What are the general recommendation when I can spare the time in testing and finding these value?
For example, is the following figures help?
Eden Space heap usage - 42MB / 62MB (used / committed)
Survivor Space heap usage - 8.5MB / 8.5MB (used / committed)
CMS Old Gen heap usage - 100MB / 217MB (used / committed)
Non-heap memory pool usage - 36MB
Ih the rare cases where i need to adjust those values there is a program called JavaVisualVM which is included in the jdk (bin folder i think) which i find very useful. You can connect to your running vm and analyze all its runtime parameters.
Under the "plugins" section you can also find a very useful plugin for monitoring the gc where you can see what exactly is going on in there.
When tuning GC, you need to collect the GC statistics over a longer period of time and then act on that. Just one snapshot of Generation size is not enough.
You should:
Enable Full GC logging. Lightweight yet powerful.
-XX:+PrintTenuringDistribution -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=jvm.log -XX:+HeapDumpOnOutOfMemoryError -Xloggc:gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -showversion
Consider additional means of collecting information about your GC. Logging is fine but there are sometimes available lightweight command-line tools that will give you even more insight. Eg.
jstat
for Hotspot which will show you occupation/capacity of Eden, Survivor and Old Gen.Compute:
Once you have this data, you can start sizing the Generations and again monitor the impact of the changes you make. The usual sizing recommendations for throughput are:
In general, sizing recommendations depend on the goal of your tuning:
See also the GC tuning question: Is there a cookbook guide for GC problems?
The general rule is that you should not change the JVM memory settings before you have discovered a problem that need to be solved. The JVM does a pretty good job in tuning most parameters in runtime to suit your application.
If you have discovered a need to optimize the memory parameters it depends on what you need to optimize. The settings you would use would vary greatly depending on which aspect you need to optimize (for example settings for minimizing pauses are very different from settings that maximize throughput).
If you really do need to optimize, please provide more information on what aspect you need to optimize.