ProfilerObjects

Profiling Objects

This page describes the Objects profiling mode.

File:objects.png

The Objects profiling mode tracks live objects and their sizes, and allocated objects and allocation call trees if configured, enabling to monitor objects currently allocated on the heap. Use this profiling mode if experiencing OutOfMemoryErrors or slowdowns caused by the garbage collector. See First Profiling Session for details on starting a profiling session.

Basic Profiling

The Objects mode is designed to provide profiling data from all classes without any initial setup. The profiling session is started by simply clicking the Profile or Attach button in toolbar. The other toolbar buttons are described in the Toolbar Buttons section.

Toolbar Buttons

  • Pause live results allows to stop updating live results. Pressed automatically when a context menu is displayed for the profiling results.
  • Update live results is enabled when the Pause live results is pressed, allows to manually update paused live results.
  • Show delta/absolute values controls switching between absolute and incremental values.
  • Take snapshot saves the currently available profiling data to a file which can be reopened later for offline analysis or compared with another snapshot.
  • Reset results clears the currently available profiling data, enabling to start collecting new data from a defined point.
  • Take thread dump action takes snapshot of all threads in the profiled JVM including their call stacks and displays it in a separate view. See the Thread Dump chapter for details.
  • Take heap dump action saves a snapshot of all objects currently stored in the heap memory in a .hprof format and optionally opens it in a heap viewer. See the Heap Dump chapter for details.
  • Request garbage collection action requests garbage collection in the profiled JVM. There's no guarantee when or if at all the garbage collection will be performed. To make sure GC will be run, the action should be invoked several times.

Results View

The default results view shows histogram of the classes currently live in the heap memory with instance numbers and sizes. The view provides the following data columns:

  • Name column shows name of the class with live instances on heap.
  • Live Bytes column shows the size of all instances of the class currently live on heap.
  • Live Objects column shows the number of all instances of the class currently live on heap.

Tip: The columns can be displayed or hidden using the right corner button in the view header by clicking the dropdown arrow (or right clicking the header on Mac OS X). The relative value bar can be displayed or hidden for every column which displays a relative value by resizing the column.

Searching And Filtering Results

A class can be found in results using the Find stripe which opens by invoking the Find action in results context menu or IDE Edit menu or using the Ctrl+F keyboard shortcut. Values of the Name column are searched for the entered substring, optionally matching case if selected. Once a search has been performed, it can be repeated using the F3 or Shift+F3 shortcuts. Next appearance of the currently selected value of Name column can be found using the Ctrl+F3 shortcut.

Collected results can be filtered using the Filter stripe which opens by invoking the Filter action in results context menu or using the Ctrl+G keyboard shortcut. Values of the Name column are filtered by the entered substring depending on the selected filter mode (Contains, Does Not Contain, Regular Expression), optionally matching case if selected. When collecting the allocation call trees, the toplevel class nodes are always displayed, only the allocating methods are filtered.

Advanced Profiling

To cover various use cases of objects profiling the profiler offers three profiling modes with different profiling techniques and settings. The modes and settings can be changed in the Settings pane which is displayed by pressing the Settings switch in Profiler window toolbar.

Objects Profiling Modes

Profiling modes
  • All classes uses sampling and shows histogram of live objects of all classes allocated on the heap, including instance numbers and sizes. This mode is selected by default and doesn't require any additional configuration.
  • Project classes uses sampling and shows histogram of live objects of project classes allocated on the heap, including instance numbers and sizes. This mode doesn't require any additional configuration.
  • Selected classes uses bytecode instrumentation and shows allocated or live instances of the defined classes including allocation call trees if configured. To use this mode, at least one class has to be selected for profiling. See the Selecting Classes For Profiling section for more information on selecting a class. See the Configuring Additional Options section for details on the additional settings.

Selecting Classes For Profiling

Selected classes instruct the profiler to only track instances of these classes, keeping the profiling overhead low. The following ways can be used to select a class or method for instrumented profiling:

  • Using the Select Class dialog. The dialog allows to select one or several classes from a project or .class/.jar file. It can be open directly from the Objects Settings pane.
  • From code editor. Java code editor provides Profile | Profile Class action in its context menu.
  • From Navigator. Java Navigator provides Profile | Profile Class action in its context menu.
  • From profiling results. Live or saved Objects results provide Profile Class actions in its context menu. Also a special column Selected is available to select classes for profiling. The column can be displayed using the right corner button in the view header by clicking the dropdown arrow (or right clicking the header on Mac OS X).

Configuring Additional Options

Based on the additional settings, the profiler can track either all allocated objects or just the objects currently live on the heap. It can also record allocation call trees to visualize from where in the source code are the objects being created. These options are available:

  • Track only live objects controls whether the profiler tracks all allocated objects from the beginning of the profiling session or last results reset (deselected) or whether the profiler tracks just the objects currently live in the heap memory (selected). When tracking only live objects, the profiler also provides a special metric Surviving Generations which helps to easily discover certain types of memory leaks.
  • Limit allocations depth controls whether the profiler collects allocation call trees and sets the depth limit for the stacks. If deselected, the profiler collects full allocation call trees. If selected, the value controls the maximum depth of allocation stacks. Zero value means no allocation call trees are being collected.

The Objects profiling mode, selected Classes and additional options can be changed at any time during a running profiling session. The changes are applied by clicking the Apply button on the right side of the settings area.

Objects Views

In case the Track only live objects option is not selected, the following data columns are available:

  • Name column shows name of the class with allocated instances.
  • Allocated Bytes column shows the size of all allocated objects from the beginning of the profiling session or last results reset.
  • Allocated Objects column shows the number of all allocated objects from the beginning of the profiling session or last results reset.

In case the Track only live objects option is selected, the following data columns are available:

  • Name column shows name of the class with live instances.
  • Live Bytes column shows the size of all instances of the class currently live on heap.
  • Live Objects column shows the number of all instances of the class currently live on heap.
  • Allocated Objects column shows the number of all allocated objects from the beginning of the profiling session or last results reset.
  • Avg. Age average object age of all instances of the class currently live on heap measured by the number of survived garbage collections.
  • Surviving Generations column shows the number of different generations measured by the number of survived garbage collections.

Tip: To provide even more control of what methods will be profiled there's a special mode with fully manual setup of profiled classes and instrumentation filter. See Features For Expert Users for details.


Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo