Skip to content

akashche/memlog_agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JVM TI agent that logs RAM usage

JVM TI agent that collects memory usage for current JVM process (using information from within the JVM and from OS) and logs it into json file.

Download

Windows x86_64 binaries built with openjdk_8u131:

To build the agent on Linux see "How to build" section below.

Usage example

Checkout a sample test-suite to run with Nashorn:

git clone https://github.com/akashche/javascript-tests-for-jvm.git
cd javascript-tests-for-jvm

Adjust agent config as needed:

  • output_path_json: path to the output JSON log
  • stdout_messages: whether to print agent init/shutdown messages to stdout
  • cron_expr: extended version of Cron expression that allows to use "seconds" field
  • timeout_divider: timeout period, defined by Cron expression will be divided by this value (to allow sub-second logging)

Run test-suite specifying path to agent. JVM arguments can be specified with -J- prefix.

See OpenJDK and Containers article for details about JVM memory usage tuning:

jjs \
    -J-XX:MaxRAM=128M \
    -J-XX:+UseSerialGC \
    -J-XX:+TieredCompilation \
    -J-XX:TieredStopAtLevel=1 \
    -J-agentpath:/path/to/libmemlog_agent.so=/path/to/config.json \
    nashornLoader.js -- baseUrl=dojo load=doh test=nashornTests

memlog.json log file will be written, with each entry looks like this:

{
    "currentTimeMillis": 1493820194707,
    "gcEventsCount": 0,
    "os": {
        "overall": 20905984,
        "VmPeak": 3686211584,
        <... more OS-specific values>
    },
    "jvm": {
        "overall": 15663104,
        "heap": {
            "committed": 8126464,
            "init": 8388608,
            "max": 1994850304,
            "used": 373832
        },
        "nonHeap": {
            "committed": 7536640,
            "init": 2555904,
            "max": -1,
            "used": 3467112
        }
    }
}

Use sample plotter.js script to convert JSON log into table format:

jjs /path/to/plotter.js memlog.json

memlog.dat file will be written:

1 20 15
2 28 16
3 34 18
...

Use gnuplot and sample plot script to create a PNG chart:

gnuplot /path/to/memlog.plot

plot

How to build

CMake is required for building.

pkg-config utility is used for dependency management. For Windows users ready-to-use binary version of pkg-config can be obtained from tools_windows_pkgconfig repository.

Build commands:

git clone --recursive https://github.com/akashche/memlog_agent.git
cd memlog_agent
mkdir build
cd build
cmake ..
cmake --build .
ctest

JAVA_HOME environment variable must be set.

On Windows using Visual Studio 2013 Express these commands can be run using Visual Studio development command prompt.

Cloning of external_jansson is not required on Linux - system Jansson library will be used instead (jansson-devel package needs to be installed).

License information

This project is released under the GNU General Public License, version 2.

Changelog

2017-05-03

  • version 1.0.0
  • initial public version