Fully featured low overhead profiler for Java EE and Java SE platforms.
Performance monitoring and profiling of Jenkins, TeamCity, Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

Persistent object IDs

An object in Java heap does not have a concept of persistent ID:

  • internally, JVM refers to objects via their physical memory addresses which may change during garbage collection if heap regions are moved or compacted;
  • object's identity hash code returned with the method java.lang.System.identityHashCode(Object) is persistent, but it's not an ID: more than one object may have the same identity hash code.

To make object identification possible, the profiler provides means to explicitly assign a persistent ID to particular objects, with the help of JVMTI object tagging. Tagging all objects is impractical because that would increase profiling overhead, JVM memory footprint and garbage collection times.

How objects can be assigned the persistent ID

  • In probes via table API: column class com.yourkit.probes.ObjectColumn is intended to record the persistent object ID, allowing to associate objects in a memory snapshot with events. For example, built-in probes for databases and file objects use it to identify the resources.
  • In a trigger for method invocation:
    • Objects whose method calls were recorded with the trigger action "Record Method Invocation" will be assigned the persistent ID. The objects can be seen in a memory snapshot (see below).
    • Macros THIS, PARAMS and RETURN_VALUE of the Print* actions have the parameter PERSISTENT_ID. Corresponding objects will be assigned the persistent ID, and the actions will output it. The IDs can be matched to objects in a memory snapshot (see below).

Important: to have access to corresponding object detail, a memory snapshot should be captured. A performance snapshot is not enough: it contains the IDs as numbers in events, but with no further information about the objects is available.

Persistent object ID presentation in the profiler UI

When a memory snapshot is opened, the persistent IDs can be seen and searched for.

  • if an object has been assigned the persistent ID, it is shown in Object explorer prefixed with # sign.
  • in Events tab: if the object corresponding to the event still exists, i.e. has not yet been collected, the hyperlink opens the object in an object explorer.
  • action Memory | (Find) Objects by Persistent ID searches for objects with particular IDs, or for all objects with the ID assigned.