Skip to main content

Querying the Java Heap

A. Sundararajan's Weblog:
"As I mentioned earlier, Mustang (Java SE 6) comes with jhat - Java Heap Analysis Tool. We have added more features to jhat as of build 53 (released on Sep, 22, 2005). jhat now comes with mechanism to query the heap. jhat supports OQL - Object Query Language -- a SQL-like language to query your Java heap!"

This is amazing news! It has, in fact, in one stroke returned my faith in the continuing evolution of Java as a valuable tool. You see, I have been thinking along similar lines for quite a long while. My thoughts, however, where not centered around the heap dump, but on integrating a heap query language into the Eclipse debugger. But given this OQL support JHat, I think it should be fairly straightforward to integrate this into the debugger. Imagine being able to define OQL queries as watch expressions, complete with difference highlighting from snapshot to snapshot. It would make debugging the state change of complex structures a breeze.

I already started a hobby project, POJOQL, which implements a small query language for heap objects. However, so far I have not found a way to traverse the heap globally. So it only runs on a given starting object. The language is different from OQL, and, I believe, better suited to quick, ad-hoc queries for structured information. For example,
  name; children{ name; children< }
lists the name of a top level object and, recursively, the names of all its children, displaying the result as a properly nested and indented structure.

Of course, LINQ in C# 3.0 clearly blows Java out of the water in this respect, but I still like the fact that Sun is thinking along these lines too.


Popular posts from this blog

Threaded chat article and demo

While nothing major, managing threaded conversations in chat has bothered me for quite a while. Yesterday I had an idea on how to improve matters:
Works using existing chat infrastructure. Needs only augmented clients.Plays well even if other party uses a non-thread aware chat tool.Separates threads automatically based on interaction patterns.I've written an article and have created an online demo about it. Discussion welcome.

Access 2003 and the DCOM Server Process Launcher

Here's a hint: Don't disable the "DCOM Server Process Launcher" service on XP SP2. It may look like one heck of a vulnerability when you really don't use DCOM at all, but, unfortunately, Microsoft Access 2003 does. It will simply open an instant message box stating "A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX Control." if the service is not running.

Beyond TDD: Documentation Driven Development

There are quite a few articles extolling the virtues of test-driven development these days (here's one). And for good reason, too. Having done TDD for quite a while, I recently started combining it with documentation-driven design. This is what my open-source tool, JCite, is all about.

With this approach, I
sketch out the most important use cases,combine them into the index of a tutorial (links plus teasers summarizing the use-case),flesh out the tutorial topics (and thus use-cases) one by one,develop the use-case tests in parallel to each topic,cite the important parts of the tests as actual code samples into the topic, andonly then start doing the implementation (this last step is accompanied by more tests, which are now more like unit-tests).In all, this is like literate programming, but of the use-case tests rather than the implementation code.

TDD already helps to make you focus on the user during API design. DDD takes the effect further by making you tell consistent and convinc…