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

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

  • By calling the profiler API static method long com.yourkit.probes.JVM.getPersistentObjectId(Object). This is the most direct and explicit way to assign the ID. Classpath requirements for using this API are explained here.
  • 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.

YourKit uses cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By browsing our website, you consent to our use of cookies and other tracking technologies in accordance with the Privacy Policy.