liveBook · Manning

Object Query Language

As explained in Troubleshooting Java: Read, debug, and optimize JVM applications

OQL is a query language for retrieving and analyzing objects and references in a Java heap dump.

Object Query Language (OQL) retrieves and analyzes objects and references in a Java heap dump. Its SQL-like queries help investigate cases that are cumbersome to compare manually, such as heap dumps from different app versions. section 11.2.3 section 11.2

Use OQL to inspect heap objects in several ways:

  • Select instances of a type, using its fully qualified class name. section 11.2.3
  • Project object attributes or derived values, and filter results by a condition. section 11.2.3
  • Find unique referrers to instances of a type; a shared referrer can help identify an object preventing garbage collection. section 11.2.3
select { name: p.name, name_length: p.name.value.length} 
from model.Product p 
where p.name.value.length > 15

This query returns each Product’s name and name length, filtering for names longer than 15 characters. section 11.2.3

How Troubleshooting Java: Read, debug, and optimize JVM applications covers it

How deep it goes
Works through instance selection, projections, filters, and referrer queries, while noting that OQL offers more functions.
Examples
Queries Product instances, attributes, name lengths, and unique referrers.
What it assumes
Assumes a Java heap dump and fully qualified class names; teaches basic selection, projection, filtering, and referrer queries.
What you can do after
Diagnose potential memory leaks by querying heap objects and examining their referrers.
How it connects
Connects heap dumps, SQL-like querying, object references, and garbage collection.

Also explained in

Compare how 2 books explain Object Query Language →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java: Read, debug, and optimize JVM applications. The section links point to the parts of the book it draws on.