Showing posts with label jdk. Show all posts
Showing posts with label jdk. Show all posts

Tuesday, 22 May 2012

Generating Java Heap Dumps on the go !

Ever come across a stituation where you need to take a look at the heap dumps , as to whats eating up the memory ?

Well depends which version of JDK u r on. The couple I know of are:


  1. jmap - a very old command which is now un supported . If u r using old versions of JDK prior to 1.5 this command is handy.
  2. jconsole - you can aquire the heap dump using the hotspotdiagnostics using the javax Mbeans. For jconsole to recognize the process , we should start the java process with the following :
-Dcom.sun.management.jmxremote.port=<PORT>   
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false
  1. jrmc - jrockit mission control - If you are on the latest versions of JDK from jrockit , this is an ultra cool utility provided to be able to diagnose and monitor and profile your jvm. Go to the Advanced ->Diagnose->heapdumpprof util and generate the heap dump at the desired location.
  2. When you startup the jvm add the arguments  -XX:+|-HeapDumpOnOutOfMemoryError and                                 -XX:HeapDumpPath=<Location where the dump should be written to>
  3. Alternatively if you are  using Jrockit you can provide the following startup arguments                                   -Djrockit.oomdiagnostics=true and  -Djrockit.oomdiagnostics.filename=d:\heapdump.log
  4. You could also monitor the memory using visualvm provided in latest jdks which give you better insight on the young heap and the old heap.
  5. Eclipse memory analyzer can also be used to generate a heap dump and also view the dum generated by any of the above processes. This is very helpful m when you want to identify memory leaks etc

        The dump thus generated usually can is a log file which you can read or a hprof file which can be analysed using a memory analyzer(eclipse plugin http://www.eclipse.org/mat/downloads.php).

       

Wednesday, 17 March 2010

Oracle Old Driver Vs New Driver

exception:code:java.lang.ArrayIndexOutOfBoundsException: 4at oracle.jdbc.driver.T4C8TTIdty.marshal(T4C8TTIdty.java:465)at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:329)at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:490)at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:202)at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:474)at

Recently while trying to work with an oracle database I came across this wierd error. Thanks to some help which I recieved from forums. I was able to get rid of this problem

This problem occurs when you are working with a new version of JDK with an older version of Oracle.

Its often good practice to check the compatibility tables for JDK , Oracle database and driver versions before trying to code.

In my case I was using ojdbc6.jar which is the latest an compatible for oracle 11g as well and works well with JDK 6. However the database I was trying to connect to was Oracle 8.1.7.

Hence this wierd error.

To solve the problem I simply added an older version driver namely classes12.jar.

Other thing to note is there is a significant difference in the package name for the OracleDriver class.

In order to find the current version of oracle you are running we can use:

select * from product_component_version