ProfilerExpertFeatures

Features For Expert Users

This page describes the expert mode of Methods and Objects profiling.

Bytecode instrumentation is a powerful tool to analyze Java applications performance and memory management. However, the profiling overhead and amount of collected data is heavily dependent on the profiler configuration. Misconfigured settings may cause extreme slowdown of the profiled process or OutOfMemoryErrors being thrown by the NetBeans JVM due to too many data.

By default the profiler offers just a limited subset of customizable options for an instrumented profiling session to prevent the abovementioned problems. While this makes the instrumenting profiler a safe choice for most of the users, it doesn't provide the full power of the profiler engine to expert users. That's why there's a special mode Defined classes which allows detailed definition of the classes to be instrumented.

The expert mode needs to be enabled using Tools | Options | Java | Profiler | General | Enable manual setup for Methods and Objects. The currently opened profiler window needs to be closed and reopened after changing this option to enable the expert mode. The mode can be set by opening the Settings pane by the rightmost Settings button in the profiler window toolbar and selecting Defined classes.

Methods Profiling

Defined classes mode of the Methods profiling allows fully manual definition of profiling roots and instrumentation filter, including wildcards.

Profiling root is a class which is instrumented (its bytecode is modified to report performance data) by the profiler at the beginning of the profiling session. Eventually all methods called from the instrumented methods are also instrumented and so on, as long as they pass the defined instrumentation filter. The rest of the application runs without any modifications at its full speed.

Instrumentation filter is a definition of which classes should or won't be instrumented. Inclusive filter defines which classes should be instrumented (typically project classes), exclusive filter defines which classes will not be instrumented (typically Java core classes, server classes). Instrumentation filter controls how many profiling data will be collected and how much will the profiler slow down the profiled application.

The Defined classes settings UI provides these two text fields:

  • Classes field defines the profiling roots.
  • Include outgoing calls or Exclude outgoing calls field defines the instrumentation filter, either inclusive or exclusive.

Both text fields define a class or set of classes and share the same format:

  • org.mypackage.** defines all classes in the org.mypackage package and all its subpackages.
  • org.mypackage.* defines all classes in the org.mypackage package.
  • org.mypackage.MyClass defines just the single org.mypackage.MyClass class.

Text field defining the instrumentation filter can also contain * or stay empty, both options are resolved as all classes.

Both text fields can define multiple values separated by a newline, empty space and/or comma.

Examples

Classes and filter definition to profile all methods of org.mypackage.MyClass class with outgoing calls except the core Java classes (approx.):

Classes:                           Exclude outgoing calls:
org.mypackage.MyClass              java.**, javax.**, sun.**, com.sun.**

Classes and filter definition to profile all methods in the org.mypackage.subpackage package with outgoing calls within the org.mypackage package and all its subpackages:

Classes:                           Include outgoing calls:
org.mypackage.subpackage.*         org.mypackage.**

Objects Profiling

Defined classes mode of the Objects profiling allows fully manual definition of what classes will be tracked by the profiler, including wildcards. Tracking only live objects and collecting allocation call trees is also possible.

The Defined classes settings UI provides these controls:

  • Classes field defines the classes to be tracked.
  • 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 text field defining the classes to be tracked uses the following format:

  • org.mypackage.** defines all classes in the org.mypackage package and all its subpackages.
  • org.mypackage.* defines all classes in the org.mypackage package.
  • org.mypackage.MyClass defines just the single org.mypackage.MyClass class.

To limit the profiling overhead, the profiler tracks only instances of Java classes created using the Object.<init> method and instances and arrays created by reflection. To track also arrays created using the new Array[] statement, the [] symbol must be explicitly used anywhere in classes definition, either as a part of array definition or separately on a new line:

  • char[] defines the primitive array of chars to be tracked.
  • [] on a newline includes arrays matching the other filters.

Using * means profiling all classes ([] on a newline includes arrays).

Multiple values can be separated by a newline, empty space and/or comma.

Examples

Classes definition to track all classes from the org.mypackage.subpackage.* package:

org.mypackage.subpackage.*

Classes definition to track all classes from the org.mypackage1 package and its subpackages and org.mypackage2.MyClass1 and org.mypackage2.MyClass2 classes:

org.mypackage1.**
org.mypackage2.MyClass1
org.mypackage2.MyClass2

Classes definition to track all instances and arrays of org.mypackage.MyClass class:

org.mypackage.MyClass
[]

Classes definition to track all primitive char and java.lang.Object arrays:

char[]
java.lang.Object[]

Classes definition to track all classes and arrays:

*
[]


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