Futuregen Skill | Online Courses - Bootcamp & R&D Platform |Online Courses - Learn Anything | No.1 Online Training in Haldwani, Uttrakhand ,India

Best Java Training Insitute with 100% Learning & Implementation

NMT Training


Native Memory Tracking

Here we will cover high level points of Native Memory Tracking (NMT) feature. NMT is a Java Hotspot VM feature that tracks internal memory usage for a HotSpot VM. You can access NMT data by using the jcmd utility. NMT does not track memory allocations for third-party native code and Oracle Java Development Kit (JDK) class libraries. NMT does not include NMT MBean in HotSpot for Java Mission Control (JMC).

Topics:

Key Features
Using Native Memory Tracking
Enabling NMT
Accessing NMT Data using jcmd
Obtaining NMT Data at VM Exit


Key Features

When you use Native Memory Tracking with jcmd, you can track Java Virtual Machine (JVM) or HotSpot VM memory usage at different levels. NMT tracks only the memory that the JVM or HotSpot VM uses, not the user's native memory. NMT doesn't give complete information for the memory used by the class data sharing (CDS) archive.

NMT for HotSpot VM is turned off by default. You can turn on NMT by using the JVM command-line option. See java in the Java Platform, Standard Edition Tools Reference for information about advanced runtime options.

You can access NMT using the jcmd utility. See Use jcmd to Access NMT Data. You can stop NMT by using the jcmd utility, but you can't start or restart NMT by using the jcmd utilty.

NMT supports the following features:

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

Using Native Memory Tracking
You must enable NMT and then use the jcmd utility to access the NMT data.

Enabling NMT

To enable NMT, use the following command-line options:

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

Accessing NMT Data using jcmd

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

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

Obtaining NMT Data at VM Exit

To obtain data for the last memory usage at VM exit, when Native Memory Tracking is enabled, we can use the following VMdiagnostic command-line options.

The level of detail is based on tracking level.

-XX:+UnlockDiagnosticVMOptions -XX:+PrintNMTStatistics

What exactly is Native Memory?

Native memory is memory allocated by the OS on behalf of the Java process through C code. This C code is called by native methods in certain Java classes.A lot of the time can get away with not thinking too much about how Java uses memory, especially native (off-heap) memory. Since profiling tools generally just ignore native memory because they cant monitor it, even if youre being a good citizen and considering the memory usage of your changes as you are developing features or fixing bugs, its easy to allow native memory utilisation to just go unchecked. When you get a heap dump from a Java process, you only get the contents of the heap, as the name implies. You will not get any real insight into what is consuming native memory unless the tool youre using has the ability to tell you that certain heap allocations may result in significant native memory usage too.

Have Queries?

Talk to our Career Counselor for more Guidance on picking the right Career for you! .

ENQUIRE NOW
7.png
shape3.png