- System requirements
- Profiler architecture
- Profiler installation
- Uninstall profiler
- Running the profiler
- Profiler activation
- Welcome screen
- Start profiling
- Profiling overhead
- Snapshots
- Solving performance problems
- CPU profiling
- Thread profiling
- Virtual threads support
- Deadlock detector
- Memory profiling
- Garbage collection
- Monitor profiling
- Exception profiling
- Telemetry
- Probes: monitor events of various kinds
- Inspections: automatic recognition of typical problems
- Automatically trigger actions on event
- Automatic deobfuscation
- Summary
- Filters
- Profiler command line
- Export of profiling results to external formats
- Profiler Java API
- Profiler HTTP API
- Settings
- Troubleshooting and FAQ
Profiler Java API
The profiler Java API allows you to control profiling programmatically right from your Java application. You can use this API to implement self-monitoring applications, or build complex JUnit memory tests by capturing and analyzing memory snapshots via the set description language.
To control profiling programmatically, please also consider HTTP API. Using language neutral tools might be more convenient and simpler in some cases.
Documentation
Here is the complete API JavaDoc.
Agent controller
The main class which allows to control profiling modes and to capture snapshots
is com.yourkit.api.controller.v2.Controller
.
To use this part of the API, please include
<Profiler Installation Directory>/lib/yjp-controller-api-redist.jar
in the classpath.
yjp-controller-api-redist.jar
is licensed under BDS-like license and
you can freely re-distribute it together with your application.
There is a sample
<Profiler Installation Directory>/samples/sample1/src/ApiDemo1.java
,
which demonstrates how the Java app can instantiate the
com.yourkit.api.controller.v2.Controller
and capture own memory snapshot.
Probes and snapshot analyzes
Classes in com.yourkit.probes.*
provide API for probes.
Classes com.yourkit.api.MemorySnapshot
and com.yourkit.api.Annotations
support the analysis of captured memory snapshots and snapshot annotation.
To use this part of the API, please include <Profiler Installation Directory>/lib/yourkit.jar
in the classpath.
Do not delete yourkit.jar
from the installation directory
and do not use a copy of yourkit.jar
in your classpath.
The API will not work with yourkit.jar
copied to another directory,
because it needs the other files from the installation.
The sample application
<Profiler Installation Directory>/samples/sample2/src/ApiDemo1.java
demonstrates how the Java app can capture own memory snapshot and analyze it.
In this sample we obtain the number of objects of particular class,
as well as their shallow and retained sizes.