OQL is a specialized query language for memory profiling of Java heap dumps. It is implemented by tools such as jvisualvm and jhat, which ship with current versions of JDK. Unfortunately, neither of these tools provides a simple command-line interface out of the box to integrate them into your own development environment and support real-life scripting. Rather, each of them gives you a kludgy and insufficient GUI.
A few notes from my playing around with OQL:
- Unfortunately, some of the handy built-in functions provided by jvisualvm are absent from jhat (need to define your own).
- To obtain object IDs that can be passed to heap.findObject you must use the built-in function objectid(objectReference). The identifiers displayed by jvisualvm that look like #nnn are not objectids (that would be too easy, eh? I don't see any way to obtain them using jvisualvm GUI, have to use OQL).
- To display the entire content of a char array (which jvisualvm cuts off in a useless way), you must use an OQL expression like objectReference.toString().
- If OQL scares you, consider buying a commercial profiler.