https://github.com/jesperpedersen/javamemflame
A JVM agent to generate flame graphs for Java memory allocation
https://github.com/jesperpedersen/javamemflame
flamegraph java-memory-allocation jvm memory-allocation
Last synced: 10 months ago
JSON representation
A JVM agent to generate flame graphs for Java memory allocation
- Host: GitHub
- URL: https://github.com/jesperpedersen/javamemflame
- Owner: jesperpedersen
- License: epl-2.0
- Created: 2015-07-09T12:50:08.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2019-04-03T11:32:46.000Z (about 7 years ago)
- Last Synced: 2025-04-23T02:35:25.457Z (about 1 year ago)
- Topics: flamegraph, java-memory-allocation, jvm, memory-allocation
- Language: Java
- Homepage:
- Size: 53.7 KB
- Stars: 16
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
javamemflame will generate a flame graph with Java memory allocation information.
## Requirements
* Java 11
* Apache Maven
## Build
```sh
mvn clean package
```
## Usage
javamemflame will record memory allocation during the lifetime of the JVM with
```sh
java -javaagent:/path/to/javamemflame.jar ...
```
Then the information can be turned into a flame graph using
```sh
java -jar /path/to/javamemflame.jar javamemflame-pid.jfr
```
The result `javamemflame-pid.svg` can be viewed with any SVG viewer, like Firefox.
## Agent options
The following agent options are supported.
* `delay=`: Delays the recording by the specified number of milliseconds.
* `duration=`: Record by the specified number of milliseconds.
Multiple options can be selected using the ',' character, like
```sh
java -javaagent:/path/to/javamemflame.jar=duration=1000,delay=500 ...
```
## Main options
### Output format
The output format of javamemflame can be controlled by
```sh
java -jar javamemflame.jar -o svg javamemflame-pid.jfr
```
Supported values
* `svg`: Flame graph
* `txt`: Text file
The text file can be turned into a flame graph using [FlameGraph](https://github.com/brendangregg/FlameGraph "FlameGraph")
```sh
/path/to/FlameGraph/flamegraph.pl --flamechart --color=java javamemflame-pid.txt > javamemflame-pid.svg
```
### Threads
javamemflame can use multiple threads to process the .jfr file faster by
```sh
java -jar javamemflame.jar -t 8 javamemflame-pid.jfr
```
### Cut off
javamemflame can filter out allocations under the specified number, and merge them together
under a `Filtered` category. F.ex. cut off at 100 MB
```sh
java -jar javamemflame.jar -c 100000000 javamemflame-pid.jfr
```
### Title
The flame graph can be given a title using
```sh
java -jar javamemflame.jar --title "My FlameGraph" javamemflame-pid.jfr
```
### Count
The number of allocation counts, instead of their combined size, can be done using
```sh
java -jar javamemflame.jar -n javamemflame-pid.jfr
```
### JFR files
Multiple .jfr files can be specified on the command line and their information will be merged
```sh
java -jar javamemflame.jar javamemflame-pid1.jfr javamemflame-pid2.jfr
```
### Package filtering
javamemflame can filter on package names, and only include their information
```sh
java -jar javamemflame.jar javamemflame-pid.jfr package[,package]*
```
## Thanks to
* [Brendan Gregg](http://github.com/brendangregg "Brendan Gregg")
## License
This project is licensed under EPL v2. See the LICENSE file.