JavaOne Conference Trip Report

Java Technology Experts Share Their Tricks!

I really enjoyed this session. They talked about ways to debug and trace Java applications.

They suggested a couple of different ways to instrument code for debugging - these are in the slide presentation available from the sessions link in the navigation bar.

They talked about stack traces. There are a few interesting states of note: LAN monitor indicates Green Threads VMs, and PCMAP Locks indicate JIT compilers. There are five thread states. If you die or hang in MS state, it indicates a problem with the VM. Think of the thread monitor like a car wash - one car can come through at one time, the rest are in MW (monitor wait) state. If your app is hanging, CW and MW state threads require attention. If your program aborts, the problem is probably native code (did you dump core?). If you just have busy states, then more stack tracing is in order.

Some performance tips.... Use jar files, but keep rarely used classes outside the jar file; this way those classes only get loaded if required. If you are using threads, create a pool of threads and use them; this saves on thread startup costs. Use buffered I/O whenever possible. And, instead of String, use the StringBuffer class; you can presize the StringBuffer to gain even more performance (the default size is only 16 characters). You can use the Reflection API with JDBC to reduce get/set method calls.