microsoft/gctoolkit
Publicmirrored from https://github.com/microsoft/gctoolkitAvailable
sample/README.md
49lines · modeblame
6790f05bMartijn Verburg4 years ago | 1 | # GCToolKit introductory sample |
8acf7744Martijn Verburg4 years ago | 2 | |
| 3 | This 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 | | |
c73e6963Martijn Verburg4 years ago | 7 | We use the Maven wrapper (`mvnw`) so you don't have to change your system wide Maven. |
| 8 | | |
8acf7744Martijn Verburg4 years ago | 9 | ### From Maven |
| 10 | | |
c73e6963Martijn Verburg4 years ago | 11 | Compile the sample with `mvnw compile`, then use `mvnw exec:exec` to run the sample. |
8acf7744Martijn Verburg4 years ago | 12 | |
| 13 | ```shell | |
c73e6963Martijn Verburg4 years ago | 14 | mvnw clean compile |
| 15 | mvnw exec:exec | |
8acf7744Martijn Verburg4 years ago | 16 | ``` |
| 17 | | |
| 18 | By default, the sample analyzes `../gclogs/preunified/cms/defnew/details/defnew.log`. Set the parameter `gcLogPath` to analyze a different GC log file. | |
| 19 | | |
| 20 | ```shell | |
c73e6963Martijn Verburg4 years ago | 21 | mvnw exec:exec -DgcLogFile=../gclogs/unified/parallel/parallelgc.log |
8acf7744Martijn Verburg4 years ago | 22 | ``` |
| 23 | | |
| 24 | ### From the command line | |
| 25 | | |
c73e6963Martijn Verburg4 years ago | 26 | The sample can also be run from the command line with Java 11 or higher. Compile the sample with `mvnw compile dependency:copy-dependencies`, |
8acf7744Martijn Verburg4 years ago | 27 | then run `java` with `--module-path` and give it the path to a GC log file as an argument. |
| 28 | | |
| 29 | ```shell | |
c73e6963Martijn Verburg4 years ago | 30 | mvnw clean compile dependency:copy-dependencies |
1ebf7e82Ken Geis4 years ago | 31 | java --module-path target/classes:target/lib --module com.microsoft.gctoolkit.sample/com.microsoft.gctoolkit.sample.Main ../gclogs/preunified/cms/defnew/details/defnew.log |
8acf7744Martijn Verburg4 years ago | 32 | ``` |
| 33 | | |
| 34 | ## Troubleshooting | |
| 35 | | |
c73e6963Martijn Verburg4 years ago | 36 | ### `mvnw exec:java` fails |
8acf7744Martijn Verburg4 years ago | 37 | |
| 38 | If you try to run the `exec:java` goal, you may see the following error: | |
| 39 | | |
| 40 | `Unable to parse configuration of mojo org.codehaus.mojo:exec-maven-plugin:3.0.0:java for parameter arguments: Cannot store value into array` | |
| 41 | | |
| 42 | This 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. | |
| 43 | | |
| 44 | ### java.nio.file.NoSuchFileException: ../gclogs/preunified/cms/defnew/details/defnew.log | |
| 45 | | |
| 46 | There are two possible issues here. | |
| 47 | | |
c73e6963Martijn Verburg4 years ago | 48 | 1. There is no `gclogs` directory in the _top-level_ directory. The sample uses `unit-test` data from building GCToolKit. Either run `mvnw test` from the _top-level_ directory, or use `-DgcLogFile=<path-to-gc-log-file>` argument to specify a log file. |
| 49 | 1. The sample is not being run from the `sample` directory. Please ensure you are in the sample directory before executing `mvnw exec:exec`. |