Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "MemoryAnalyzer/OQL"

(OQL (Memory Analyzer) versus SQL (MAT/Calcite))
(= SELECT DISTINCT)
Line 70: Line 70:
 
Various updates and enhancements have been made to OQL. These are availabe from nightly builds for testing and are subject to change.
 
Various updates and enhancements have been made to OQL. These are availabe from nightly builds for testing and are subject to change.
  
=== SELECT DISTINCT ==
+
== SELECT DISTINCT ==
  
 
`DISTINCT` used to just operate on the results of a query if it returned objects rather than general select items.
 
`DISTINCT` used to just operate on the results of a query if it returned objects rather than general select items.

Revision as of 04:12, 18 November 2019

Object Query Language

Object Query Language is an SQL like language used by Memory Analyzer for exploring a heap dump.

Simple

SELECT * FROM java.lang.String

Displays all String objects as a tree.

SELECT s as String,s.value as "characters" FROM java.lang.String s

Displays all String objects as a table.

SELECT s as String,s.value as "characters", inbounds(s),inbounds(s).@length FROM java.lang.String s

String                          |characters                                 |inbounds(s)| inbounds(s).@length
--------------------------------------------------------------------------------------------------------------
java.lang.String [id=0x22e58820]|char[] [id=0x22e60f50;length=16;size=48]   |[I@620f7a39|                   1
java.lang.String [id=0x22e59150]|char[] [id=0x22e62ff0;length=6;size=24]    |[I@1f7b8d59|                   1
java.lang.String [id=0x22e5b560]|char[] [id=0x22e6b730;length=537;size=1088]|[I@28551755|                   1
--------------------------------------------------------------------------------------------------------------

There are two sorts of objects encountered with OQL, IObject which represent Java objects in the snapshot and regular Java objects generated by OQL processing.

java.lang.String [id=0x22e58820] is a IInstance representing a String from the snapshot.

char[] [id=0x22e60f50;length=16;size=48] is an IPrimitiveArray representing a character array from the snapshot.

[I@620f7a39 is a regular Java integer array holding a several of ints which are the object IDs Memory Analyzer uses to represent IObjects in the snapshot.


OQL (Memory Analyzer) versus SQL (MAT/Calcite)

As well as the built-in OQL, there is an extension plug-in for MAT called MAT Calcite which adds SQL processing

Topic OQL SQL
General syntax SELECT s FROM java.lang.String s SELECT s.this FROM "java.lang.String" s
Built-in functions SELECT toString(s), classof(s), s.@objectAddress, s.@usedHeapSize, s.@retainedHeapSize FROM java.lang.String s SELECT toString(s.this),getType(s.this),getAddress(s.this),shallowSize(s.this),retainedSize(s.this) FROM "java.lang.String" s
More functions SELECT h, h[0:-1].size(), h.table, h.table.@length, h.modCount, h.getField("modCount") FROM java.util.HashMap h SELECT h.this,getSize(h.this),h.this['table'],length(h.this['table']), h.this['modCount'], getField(h.this,'modCount') FROM "java.util.HashMap" h

Enhancements in November 2019

Various updates and enhancements have been made to OQL. These are availabe from nightly builds for testing and are subject to change.

SELECT DISTINCT

`DISTINCT` used to just operate on the results of a query if it returned objects rather than general select items.

SELECT DISTINCT OBJECTS classof(s) FROM "java.lang..S*" s

SELECT * FROM OBJECTS "java.lang.S.*"

`DISTINCT` now also operates on SELECTs with select items. It uses the whole row considered as a list as the item to be considered as distinct. It also uses the optimization that the input FROM items are also considered as being distinct (either as ints/IObjects or more general `FROM` items).

SELECT DISTINCT classof(s) FROM "java.lang..S*" s

Back to the top