Documentation Contents

# Native Memory Tracking

- Overview
- Key Features
- How to Use Native Memory Tracking
  - Enable NMT
  - Use jcmd to Access NMT Data
- NMT at VM Exit

## Overview

The Native Memory Tracking (NMT) is a Java Hotspot VM feature that tracks internal memory usage for a HotSpot JVM. You can access NMT data using jcmd utility. NMT in this release does not track third party native code memory allocations and JDK class libraries. Also, this release does not include NMT `MBean` in HotSpot for JMC.

## Key Features

Native Memory Tracking has the following features and when used with jcmd can track memory usage at differnet levels.

- NMT for Hotspot VM is turned off by default. Turn this feature on using JVM command line option. See the Native Memory Tracking command man page.

- Memory tracking data can be accessed using jcmd utility. See use jcmd to access NMT data.

- Generate summary and detail reports.

- Establish an early baseline for later comparison.

- Request a memory usage report at JVM exit with the JVM command line option. See NMT at VM exit.

- NMT can be shutdown using jcmd utility, but can not start/restart using jcmd.

## How to Use Native Memory Tracking

First enable NMT and then use jcmd to access the data collected thus far.

### Enable NMT

Enable NMT using the following command line. Note that enabling this will cause 5-10% performance overhead.

`-XX:NativeMemoryTracking=[off | summary | detail]`

off | NMT is turned off by default.
summary | Only collect memory usage aggregated by subsystem.
detail | Collect memory usage by individual call sites.

### Use jcmd to Access NMT Data

Use jcmd to dump the data collected and optionally compare it to the last baseline.

`jcmd <pid> VM.native_memory [summary | detail | baseline | summary.diff | detail.diff | shutdown] [scale= KB | MB | GB]`

summary | Print a summary aggregated by category.
detail | Print memory usage aggregated by category Print virtual memory map Print memory usage aggregated by call site
baseline | Create a new memory usage snapshot to diff against.
summary.diff | Print a new summary report against the last baseline.
detail.diff | Print a new detail report against the last baseline.
shutdown | Shutdown NMT.

## NMT at VM Exit

Use the following VM diagnostic command line option to obtain last memory usage data at VM exit when Native Memory Tracking is enabled. The level of detail is based on tracking level.

`-XX:+UnlockDiagnosticVMOptions -XX:+PrintNMTStatistics`

See Troubleshooting Guide on how to monitor VM internal memory allocations and diagnose VM memory leaks.

Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved.
Contact Us