Properties of heap objects are accessed using a simple dot notation:
[ <alias>. ] <field> . <field>. <field>
An alias can be defined in the FROM Clause to identify the current object, i.e. row in the SQL analogy, on which the OQL statement operates. Without alias, the field is assumed to be one of the fields of the current object. Fields are attributes of the Java objects in the heap dump. Use OQL autocompletion or the Object Inspector to find out about the available fields of an object.
[ <alias>. ] @<attribute> ...
Using the @ symbol, OQL accesses attributes of the underlying Java objects used by Memory Analyzer to represent objects in the heap dump. The attributes are resolved via Bean Introspection. Use OQL autocompletion to find the common beans names. The following table lists some commonly used Java attributes.
Any heap object | IObject | objectId | id of snapshot object |
objectAddress | address of snapshot object | ||
class | Java class of this object | ||
clazz | IClass of this object. See also classof(object). | ||
usedHeapSize | shallow heap size | ||
retainedHeapSize | retained heap size | ||
displayName | display name | ||
Class object | IClass | classLoaderId | id of the class loader |
Any array | IArray | length | length of the array |
Primitive array | IPrimitiveArray | valueArray | the values in the array |
Reference array | IObjectArray | referenceArray | the objects in the array (as long values, the addresses of the objects) Access a particular element using get() and convert to an object using OBJECTS. |
[ <alias> . ] @<method>( [ <expression>, <expression> ] ) ...
Adding ( ) forces OQL to interpret this as a Java method call. The call is executed via reflection. The following table lists some common Java methods on the underlying Java objects used by Memory Analyzer to represent objects in the heap dump.
${snapshot} | ISnapshot |
getClasses() |
a collection of all classes |
getClassesByName(String name, boolean includeSubClasses) |
a collection of classes | ||
Class object | IClass |
hasSuperClass() |
result is true if the class has a super class |
isArrayType() |
the result is true if the class is an array type | ||
Any heap object | IObject |
getObjectAddress() |
The address of a snapshot object as a long integer |
Primitive array | IPrimitiveArray |
getValueAt(int index) |
a value from the array |
Java primitive array, Java object array or Java list (returned from reflection) | [] or List |
get(int index) |
a value from the array or list |
Memory Analyzer 1.3 or later allows direct array style access of primitive arrays and objects arrays from the snapshot, and Java arrays and Java Lists obtained from reflective method calls. The notation is [index]. The index is an integer. If the array is null or the index is out of range then the result is null.
SELECT s[2] FROM int[] s WHERE (s.@length > 2)
This method is for Memory Analyzer 1.3 or later.
SELECT s.getValueAt(2) FROM int[] s WHERE (s.@length > 2)
This method is for all versions of Memory Analyzer. This reads the value of the element at index 2 from all int[] arrays which have at least 3 elements.
SELECT s[2] FROM java.lang.Object[] s WHERE (s.@length > 2)
This method is for Memory Analyzer 1.3 or later. s[2]is an IObject so fields and Java bean properties can be accessed
SELECT OBJECTS s[2] FROM java.lang.Object[] s
This method is for Memory Analyzer 1.3 or later. The OBJECTS converts the object to give a tree view rather than table result. We do not need the WHERE clause as out of range accesses return null and the OBJECTS skips nulls.
SELECT OBJECTS s.@referenceArray.get(2) FROM java.lang.Object[] s WHERE (s.@length > 2)
This method is for Memory Analyzer 1.1 or later. This reads as a long address the element at index 2 from all Object[] arrays which have at least 3 elements and converts them into objects.
SELECT OBJECTS s.getReferenceArray(2,1) FROM java.lang.Object[] s WHERE (s.@length > 2)
This method is for Memory Analyzer 1.1 or later. This reads as an array of long[] 1 element starting at index 2 from all Object[] arrays which have at least 3 elements and converts the contents of those arrays into objects.
SELECT s.@GCRoots[2] FROM OBJECTS ${snapshot} s
This method is for Memory Analyzer 1.3 or later.
SELECT s.get(2) FROM OBJECTS ${snapshot} s WHERE s.@GCRoots.@length > 2
This method is for all versions of Memory Analyzer.
SELECT s.@GCRoots.subList(1,3)[1] FROM OBJECTS ${snapshot} s
This method is for Memory Analyzer 1.3 or later.
SELECT s.@GCRoots.subList(1,3).get(1) FROM OBJECTS ${snapshot} s
This method is for all versions of Memory Analyzer.
<function>( <parameter> )
Built-in functions.
toHex( number ) |
Print the number as hexadecimal |
toString( object ) |
Returns the value of an object, e.g. the content of a String etc. |
dominators( object ) |
The objects immediately dominated by the object |
outbounds( object ) |
outbound referrer |
inbounds( object ) |
inbound referrer |
classof( object ) |
the class of the current object |
dominatorof( object ) |
the immediate dominator, -1 if none |