Prefetch Technologies // Keeping your cache lines cozy

Archive

Posts in Java

Finding bugs in Java programs

javaDec 16, 2007 1 min read

A while back I came across findbugs, which is a static analysis tool that can be used to locate bugs in Java programs. Findbugs is able to identify a number of bug patterns, which range from bad practices to performance and multithreaded programming bugs. Findbugs can be invoked through a graphical utility, or by running the findbugs command line utility. The command line option has the advantage that it can be easily incorporated into existing build processes (there are options readily available to integrate findbugs with maven and ant), allowing code to be tested when new builds are created…

$ read more →

Generating byte code from a Java class file

javaDec 16, 2007 1 min

I have been reading through the Java virtual machine specification, which covers all the details needed to implement a JVM. Once thing the specification talks about in detail is Java bytecode, which is the machine independent code that is executed by the virtual machine implementation. At various places in the specification I wondered what the byte code would look like for a chunk of Java code. Fortunately for me, the Java SDK comes with the javap utility, which can be run with the "-c" option to translate a class file into byte code: In the output above, you can see the methods and constants the MyEnv class utilizes, and the byte code that makes up the main method in the MyEnv class…

$ read more →

Using the DTrace hotspot provider to observe java object allocations

javadtraceOct 31, 2007 3 min

In my previous post, I discussed how jmap can be used to view the contents of the Java heap. Jmap is a wonderful utility for viewing heap utilization at a specific point in time, but it's not the best utiltiy for answer questions like "which call stack is allocating objects of type foo?", or "how many objects are being allocated per second?", or "what is the average size of allocated objects?". To answer these types of questions, we need to look to a more thorough instrumentation framework. One such framework is the DTrace hotspot provider which was introduced in Java 6, and provides a number of probes to dynamically instrument Java applications…

$ read more →

Summarizing Java heap utilization with jmap

javaOct 27, 2007 3 min

Java has become one of the most successful languages to hit the IT industry. One of the reasons behind it's high rate of adoption is that fact that Java manages memory resources for the programmer. This makes programming significantly easier, but introduces additional complexity, since engineers need to size the Java heap and pick a garbage collection algorithm (or in the case of generational collectors, more than one) that best matches an application's workload. Fortunately, two extremely useful tools allow you to observe the Java heap: the DTrace hotspot provider and the Java jmap utility…

$ read more →

Viewing Java stack traces with jstack

javaMay 21, 2006 1 min

I wrote yesterday about the jmap utility, which is a great utility for better understanding the arrangement of the JVM's heap. Each thread that lives inside the JVM also contains an execution stack, which is used to store local variables and state information to allow function calls to work. The Java SDK /JRE comes with the jstack utility, which can be used to print the stack of each thread in human readable form: Each stack frame contains the state (e.g., runnable, blocked, etc) of the thread and a stack backtrace with the current stack frame displayed first. Good stuff!

$ read more →