The FROM clause defines the classes on which to operate. Specify the class by one of the following means:
by class name:SELECT * FROM java.lang.Stringby a regular expression matching the class name:
SELECT * FROM "java\.lang\..*"by the object address of the class:
SELECT * FROM 0x2b7468c8by the object addresses of more than one class:
SELECT * FROM 0x2b7468c8,0x2b74aee0by the object id of the class:
SELECT * FROM 20815by the object ids of more than one class:
SELECT * FROM 20815,20975by a sub select:
SELECT * FROM ( SELECT * FROM java.lang.Class c WHERE c implements org.eclipse.mat.snapshot.model.IClass )
The statement returns all objects in the heap. The implements check is necessary, as the heap dump can contain java.lang.Class instances caused by proxy classes or classes representing primitive types such as int.class or Integer.TYPE. The following query has the same effect, which calls a method directly on the ISnapshot object:
SELECT * FROM ${snapshot}.getClasses()
Use the INSTANCEOF keyword to include objects of sub-classes into the query:
SELECT * FROM INSTANCEOF java.lang.ref.Reference
The resulting table contains, amongst others, WeakReference and SoftReference objects because both classes extend from java.lang.ref.Reference . By the way, the same result has the following query
SELECT * FROM ${snapshot}.getClassesByName("java.lang.ref.Reference", true)
Use the OBJECTS keyword if you do not want to process the term as classes. Specify the object or objects by one of the following means:
by class name:SELECT * FROM OBJECTS java.lang.String
The result is just one object, the java.lang.String class object.
by the object address of the particular object:SELECT * FROM OBJECTS 0x2b7468c8by the object addresses of particular objects:
SELECT * FROM OBJECTS 0x2b7468c8,0x2b746868by the object id of the particular object:
SELECT * FROM OBJECTS 20815by the object ids of particular objects:
SELECT * FROM OBJECTS 20815,20814by a sub expression (Memory Analyzer 1.4 or later):
SELECT * FROM OBJECTS (1 + ${snapshot}.GCRoots.length)by a sub select returning an object list
SELECT v, v.@length FROM OBJECTS ( SELECT OBJECTS s.value FROM java.lang.String s ) vIn Memory Analyzer 1.10 and later, sub-selects are now also permitted which have select items.
SELECT v,v.s,v.val FROM OBJECTS ( SELECT s,s.value as val FROM java.lang.String s ) vSee Wiki Sub select with select items for more details.
The OQL pane now has autocompletion for class names, class name regular expressions, field names, attributes and methods. See OQL autocompletion.