Property Accessors

Accessing fields of the heap object

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 the Object Inspector to find out about the available fields of an object.

Accessing Java Bean properties

[ <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. 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.

Calling Java methods

[ <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

Reading values from primitive arrays

SELECT s.getValueAt(2) FROM int[] s WHERE (s.@length > 2)

This reads the value of the element at index 2 from all int[] arrays which have at least 3 elements.

Reading objects from object arrays

SELECT OBJECTS s.@referenceArray.get(2) FROM java.lang.Object[] s WHERE (s.@length > 2)

First method: 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)

Second method: 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.

Built-in OQL functions

<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