The SELECT clause determines what to extract from the heap dump. To display objects and be able to browse the outgoing references, use the * symbol:
SELECT * FROM java.lang.String
Select specific columns
Alternatively, one can select the fields to be displayed:
SELECT toString(s), s.count, s.value FROM java.lang.String s
The resulting table knows about the underlying object. So you can use the context menu to open further views on the object at hand. Use the @ symbol to access Java attributes and methods of the objects. There are also a number of built-in functions available to extract common information:
SELECT toString(s), s.@usedHeapSize, s.@retainedHeapSize FROM java.lang.String s
The section on Property Accessors contains details on the commonly available attributes.
Provide column names
Use the AS keyword to name the columns:
SELECT toString(s) AS Value, s.@usedHeapSize AS "Shallow Size", s.@retainedHeapSize AS "Retained Size" FROM java.lang.String s
Use the AS RETAINED SET keyword to get the set of objects retained by your selection:
SELECT AS RETAINED SET * FROM java.lang.String
Flatten select items into an object list
Use the OBJECTS to interpret the items in the SELECT clause as objects:
SELECT OBJECTS dominators(s) FROM java.lang.String s
The function dominators() returns an array of objects. Therefore the query returns a list of object lists, i.e. arrays. By using the keyword OBJECTS , we force the OQL to reduce this into a single list of objects.
Select unique objects
Use the DISTINCT keyword to only select unique objects:
SELECT DISTINCT * FROM OBJECTS 0,1,1,2
Use the DISTINCT OBJECTS keyword to only select unique objects from the result of the selected clause:
SELECT DISTINCT OBJECTS classof(s) FROM java.lang.String s
The function classof returns the class object. Of course, all Strings have the same class. The OBJECTS converts the underlying row with a String object and a displayed value of the class object to the object represented by the result of the classof function. Without the DISTINCT OBJECTS keywords, the query would result in a list with as many rows with the same class as there are Strings.
Expressions (experimental, Memory Analyzer 1.4)
Use the expressions for the select item, including string concatenation:
SELECT s.@objectId, s.@objectId * 2, "The object ID is "+@objectId FROM OBJECTS 0,1,1,2 s
With Memory Analyzer 1.4 expressions and sub-selects are allowed for select items. More complex expressions may need to be parenthesized. This is currently in the test phase.