-
Notifications
You must be signed in to change notification settings - Fork 816
Embedded profiling as Java Agent
Andrey Pangin edited this page Mar 13, 2021
·
3 revisions
If you need to profile some code as soon as the JVM starts up, instead of using the profiler.sh
script,
it is possible to attach async-profiler as an agent on the command line. For example:
$ java -agentpath:/path/to/libasyncProfiler.so=start,event=cpu,file=profile.html ...
Agent library is configured through the JVMTI argument interface.
The format of the arguments string is described
in the source code.
The profiler.sh
script actually converts command line arguments to that format.
For instance, -e wall
is converted to event=wall
, -f profile.html
is converted to file=profile.html
, and so on. However, some arguments are processed
directly by profiler.sh
script. E.g. -d 5
results in 3 actions:
attaching profiler agent with start command, sleeping for 5 seconds,
and then attaching the agent again with stop command.