Showing posts with label JVM. Show all posts
Showing posts with label JVM. Show all posts

Thursday, October 28, 2010

Setting WebSphere JVM Heap size without the web console

It seems that when you update the JVM Heap size settings for WebSphere through the web console via:

Servers > Application Servers > WebSphere_Portal > Server Infrastructure > Java and Process Management > Process Definition > Java Virtual Machine > Maximum/Minimum Heap Size

There is no warning at all about setting the minimum value and NOT setting the maximum value.  The maximum value by default is 256mb, so if by any chance you set the minimum to 512mb and you go get  a coffee while restarting the server, you will get the following error message in the native_stderr.log file:


“Could not create the Java virtual machine.
JVMJ9GC019E -Xms too large for -xmx “

The message is quite clear, but it doesn’t say where to change this setting and by now you will notice that your server won’t start and you have no access to the web console in order to change the settings.

So how to solve this? find the server.xml config file, that could be located in path similar to this one:

“C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\config\cells\mycomputernameNode01Cell\nodes\mycomputernameNode01\servers\server1″

Please make a BACKUP before proceeding.

Then look for the “jvmEntries” xml element that could look like this:

initialHeapSize=”512″ runHProf=”false” debugMode=”false” debugArgs=”-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777″ disableJIT=”false”>


Now you can either:
  • Remove the “initialHeapSize” attribute
  • Modify the value to something equal or below 256mb (the default)
  • Add the “maximumHeapSize” and set it to equal or more than the initial, in this case 512mb
Save the file and your server should be ready to go.

Thursday, July 29, 2010

JVM Heap Size Tuning

Earlier this week I had to solve a major performance issue affecting our application, in the end it turned out to be a database (missing statistics) problem that lead to a slow response from a query, but in the mean time I had the opportunity to play a little bit more with Websphere’s JVM Heap size settings.

First of all, what is the JVM Heap size? The simple answer is: The amount of memory used by the virtual machine to allocate new objects created by your Java applications.

You can find tons of details about it online, but here I’ll post the main ones:

·It directly affects performance, so it’s one of the most important JVM tuning parameters

·If you set the max heap size too low, your apps will reach the max level soon and you’ll get the following error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

·In case you choose big amount for the max heap size setting, then your applications will have all the room needed to create objects, but then the Garbage Collection (GC) process will take longer. The effect of this setting will depend on the GC policy you choose.

By default the GC policy is set to “Optthruput” which means your app will not respond during GC. The second option is “Optavgpause”, that runs the GC concurrently with the app and gives a better response time. Finally “Gencon”, that treats long-lived and short-lived objects in a different way by allocating the latter ones in a special area (Nursery space) that can be disposed more often, hence reducing the time spent during GC.

In the end the value of the heap size will depend on the needs and resources available in each case, so now it’s time for you to go and give it a try ;)

Sunday, May 16, 2010

OpenJDK or Sun's JDK?

Did you just install Ubuntu and noticed that OpenJDK is the default Java Virtual Machine? I have nothing against OpenJDK but some programs require the Sun version.

The good news is that you don't have remove neither of them cause both can live happily next to each other and all it takes to switch from one version to another is the following command:

sudo update-alternatives --config java