Giter Club home page Giter Club logo

hprof-slurp's Introduction

hprof-slurp

Build status Crates.io

hprof-slurp is a specialized JVM heap dump analyzer.

It is named after the hprof format which is used by the JDK to encode heap dumps.

The design of this tool is described in details in the following blog articles series.

Motivation

The underlying motivation is to enable the analysis of huge heap dumps which are much larger than the amount of RAM available on the host system.

hprof-slurp processes dump files in a streaming fashion in a single pass without storing intermediary results on the host.

This approach makes it possible to provide an extremely fast overview of dump files without the need to spin up expensive beefy instance.

However, it does not replace tools like Eclipse Mat and VisualVM which provide more advanced features at a different cost.

Features

  • displays top n allocated classes.
  • displays number of instances per class.
  • displays largest instance size per class.
  • displays threads stack traces.
  • lists all Strings found.

Usage

./hprof-slurp --help
JVM heap dump hprof file analyzer

Usage: hprof-slurp [OPTIONS] --inputFile <inputFile>

Options:
  -i, --inputFile <inputFile>  binary hprof input file
  -t, --top <top>              the top results to display [default: 20]
  -d, --debug                  debug info
  -l, --listStrings            list all Strings found
  -h, --help                   Print help
  -V, --version                Print version

Example:

./hprof-slurp -i "test-heap-dumps/hprof-64.bin"
Found a total of 2.53MiB of instances allocated on the heap.

Top 20 allocated classes:

+------------+-----------+-------------+----------------------------------------------+
| Total size | Instances |     Largest | Class name                                   |
+------------+-----------+-------------+----------------------------------------------+
|    1.99MiB |       436 |   634.78KiB | int[]                                        |
|  197.11KiB |      1991 |    16.02KiB | char[]                                       |
|   85.25KiB |       443 |     8.02KiB | byte[]                                       |
|   47.38KiB |      1516 |  32.00bytes | java.lang.String                             |
|   45.42KiB |       560 |     8.02KiB | java.lang.Object[]                           |
|   15.26KiB |       126 | 124.00bytes | java.lang.reflect.Field                      |
|   14.77KiB |       378 |  40.00bytes | java.util.LinkedList$Node                    |
|    9.94KiB |       212 |  48.00bytes | java.util.HashMap$Node                       |
|    8.91KiB |       190 |  48.00bytes | java.util.LinkedList                         |
|    8.42KiB |        98 |  88.00bytes | java.lang.ref.SoftReference                  |
|    6.05KiB |       258 |  24.00bytes | java.lang.Integer                            |
|    5.91KiB |        18 |     2.02KiB | java.util.HashMap$Node[]                     |
|    5.86KiB |       150 |  40.00bytes | java.lang.StringBuilder                      |
|    5.44KiB |       116 |  48.00bytes | java.util.Hashtable$Entry                    |
|    5.05KiB |        38 | 136.00bytes | sun.util.locale.LocaleObjectCache$CacheEntry |
|    5.00KiB |        40 | 128.00bytes | java.lang.ref.Finalizer                      |
|    3.50KiB |        32 | 112.00bytes | java.net.URL                                 |
|    3.42KiB |        73 |  48.00bytes | java.io.File                                 |
|    3.17KiB |        12 | 776.00bytes | java.util.Hashtable$Entry[]                  |
|    3.13KiB |        56 | 144.00bytes | java.lang.String[]                           |
+------------+-----------+-------------+----------------------------------------------+

Installation

Releases

Using the provided binaries in https://github.com/agourlay/hprof-slurp/releases

Crates.io

Using Cargo via crates.io.

cargo install hprof-slurp

Performance

On modern hardware hprof-slurp can process heap dump files at around 1GB/s.

To maximize performance make sure to run on a host with at least 4 cores.

Limitations

  • Tested only with JAVA PROFILE 1.0.2 & JAVA PROFILE 1.0.1 formats.
  • Does not support dumps generated by 32 bits JVM.

Generate a heap dump

Heap dump files are sometimes generated in case of a JVM crash depending on your runtime configuration.

It can also be done manually by triggering a heap dump using jmap.

Example:

jmap -dump:format=b,file=my-hprof-file.bin <pid>

Prior art of HPROF parsing

Several projects have been very useful while researching and implementing this tool. They have provided guidance and inspiration in moments of uncertainty.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.