microsoft/gctoolkit

Public

mirrored from https://github.com/microsoft/gctoolkitAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
11cd0c0d4ea83f9017065cd67dfe38aba722091e

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

sample/README.md

47lines · modecode

1# GCToolKit introductory sample
2
3This sample shows how to use [GCToolKit](../README.md) to analyze a GC log file and report on total heap occupancy after a GC cycle has been completed. For more details on how GCToolKit and this sample work, visit [Introducing Microsoft GCToolKit](https://devblogs.microsoft.com/java/introducing-microsoft-gctoolkit/).
4
5## To run the sample
6
7### From Maven
8
9Compile the sample with `mvn compile`, then use `mvn exec:exec` to run the sample.
10
11```shell
12$ mvn clean compile
13$ mvn exec:exec
14```
15
16By default, the sample analyzes `../gclogs/preunified/cms/defnew/details/defnew.log`. Set the parameter `gcLogPath` to analyze a different GC log file.
17
18```shell
19mvn exec:exec -DgcLogFile=../gclogs/unified/parallel/parallelgc.log
20```
21
22### From the command line
23
24The sample can also be run from the command line with Java 11 or higher. Compile the sample with `mvn compile dependency:copy-dependencies`,
25then run `java` with `--module-path` and give it the path to a GC log file as an argument.
26
27```shell
28$ mvn clean compile dependency:copy-dependencies
29$ java java --module-path target/classes:target/lib --module gctoolkit.sample/com.microsoft.gctoolkit.sample.Main ../gclogs/preunified/cms/defnew/details/defnew.log
30```
31
32## Troubleshooting
33
34### `mvn exec:java` fails
35
36If you try to run the `exec:java` goal, you may see the following error:
37
38`Unable to parse configuration of mojo org.codehaus.mojo:exec-maven-plugin:3.0.0:java for parameter arguments: Cannot store value into array`
39
40This has something to do with the [Exec Maven Plugin](https://www.mojohaus.org/exec-maven-plugin/), which automatically builds the command line from the project dependencies. But it is unclear exactly what the cause of this issue is. The solution is to use the `exec:exec` goal.
41
42### java.nio.file.NoSuchFileException: ../gclogs/preunified/cms/defnew/details/defnew.log
43
44There are two possible issues here.
45
461. There is no `gclogs` directory in the _top-level_ directory. The sample uses `unit-test` data from building GCToolKit. Either run `mvn test` from the _top-level_ directory, or use `-DgcLogFile=<path-to-gc-log-file>` argument to specify a log file.
471. The sample is not being run from the `sample` directory. Please ensure you are in the sample directory before executing `mvn exec:exec`.