Tracking Java Native Memory with JDK Flight Recorder

JDK Flight Recorder (JFR) is a valuable tool for observing the runtime characteristics of Java applications and identifying performance issues. One recent addition to JFR is support for native memory tracking (NMT), which provides detailed insight into the memory consumption of your application. Previously, accessing NMT required using the jcmd command line tool, but now with Java 20, you can record NMT data continuously with JFR using two new event types. This makes it easier to collect and analyze data over a longer period of time. You can also expose a live stream of NMT data to remote clients for integration with dashboards and monitoring solutions. NMT in JFR is controlled via the gc setting and must be enabled using the -XX:NativeMemoryTracking JVM option. Using JFR, you can track off-heap allocations and overall memory consumption of your application. NMT does come with a performance overhead, but Java 21 introduces the “Resident Set Size” event type to track memory consumption on an ongoing basis. This can be useful for analyzing memory usage over time and correlating it with other events. JFR event streaming allows for live monitoring and triggering alerts based on memory growth.

https://www.morling.dev/blog/tracking-java-native-memory-with-jdk-flight-recorder/

To top