# Selecting Queries

Memory Analyzer provides a set of queries to analyze a heap dump. These queries are grouped into several categories.

You can select a query out of the drop-down toolbar menu.

In the menu you can also access the list of already executed queries via the History entry. The Query Selector which can be quickly accessed with the ctrl+Q or command+Q key combination.

The Query Selector consists of an input field, where you can search for queries, below the input field you can find the history of already executed queries and below the history the list of all available queries grouped by their category. When a query is selected, a detailed description of the query is displayed at the bottom. This description contains also the information about the arguments for this query. To execute the query either double-click or press enter.

The input field can also be used to execute queries via the command line. Either type the command name you want together with the arguments, or copy the example arguments from a command in the list by using ctrl+enter or command+enter on macOS) or mouse button 2. Then execute the query by pressing enter which will execute the command directly if all required arguments have been specified, or will bring up the arguments wizard if other arguments are required. Pressing shift+enter will always bring up the arguments wizard if there any arguments which could be changed.

Try the Query Browser or the Query History Browser now.

The query browser ("Search Queries...") is also available in the context menu. * The query browser is easier to use as it can display some or all the queries, and shows also the help for each query. It offers only queries valid for the current selection. For example, queries operating on the whole dump would only be offered in the drop down menu from the task bar. Queries operating on single objects would not be offered from the content menu when multiple objects or rows are selected. The pop-up context menu excludes queries where the selection does not include any objects of the type required by the query. Those queries would still be available using the query browser.

If a query has arguments a wizard is opened up when the query is selected. All arguments are displayed in an table, the mandatory arguments are bold. In the message area at the top information is displayed about the mandatory arguments. At the bottom the detailed description is displayed like in the query selector.

Providing Query Arguments

To add the arguments to a query you may use a query browser or an arguments dialog.

Mandatory arguments are in boldface. Tooltips and help infopop that are below the dialog provide argument description. The message area of the dialog itself shows information about the selected argument or an error message if you have entered a not valid value. Some queries require a set of objects as an argument. You can provide those objects using the simple or the advanced mode of the dialog. On the figure below you can see the simple mode. A set of objects is defined by a pattern.

Pattern Syntax

The metacharacters that are supported by a pattern are:(, [, { ,\, ^, -, $, |, ], }, ), ?, * and +.

Pattern Syntax | Details
--- | ---

    [abc]

a, b, or c (simple class)

    [^abc]

Any character except a, b, or c (negation)

    outbounds( object )

outbound referrer

    [a-zA-Z]

a through z, or A through Z, inclusive (range)

    [a-d[m-p]]

a through d, or m through p: [a-dm-p] (union)

    [a-z&&[def]]

d, e, or f (intersection)

    [a-z&&[^bc]]

a through z, except for b and c: [ad-z] (subtraction)

    [a-z&&[^m-p]]

a through z, and not m through p: [a-lq-z] (subtraction)

    \d

A digit: [0-9]

    \D

A non-digit: [^0-9]

    \s

A whitespace character: [ \t\n\x0B\f\r]

    \S

A non-whitespace character: [^\s]

    \w

A word character: [a-zA-Z_0-9]

    \W

A non-word character: [^\w]

In advanced mode, you can define a set of objects with a pattern, object addresses or an Object Query Language (OQL) query. Icons and help messages give you information about the type of the argument.

You may enter a single parameter per line, such as a pattern, an object address, or an OQL query. Additional line for this type of the argument is added automatically, thus multiple arguments can be entered.

Object Address Syntax

The object address has a hexadecimal form, that is it starts with the hex-prefix 0x and consists of one or more letters A-F and digits 0-9.

Example: 0x36d99c88

For more information about OQL, refer to the OQL syntax details

-include_class_instance

If there is a class pattern then the class object will also be returned as well as the instances.

-include_subclasses

If there is a class pattern then instances of that class and instances of subclasses of that class will be returned.

-include_loaded_instances

If the object or objects are all class loaders then the classes loaded by those loaders will be returned as well as the class loaders.

-retained

The objects retained by the selected objects will also be returned.

-verbose

Can only be set via the command line with the query browser. Used to see how objects are returned from the specified heap object argument.

Related reference

- Query Matrix