JDK Flight Recorder (JFR) gained support for Native Memory Tracking (NMT) starting in Java 20, enabling continuous recording of JVM memory consumption beyond the heap. Two new JFR event types cover total native memory usage and per-type breakdowns. The post walks through a practical example allocating off-heap memory via direct ByteBuffer and the Foreign Memory API, showing how allocations appear in JFR recordings viewed in JDK Mission Control. It also covers the Resident Set Size (RSS) event added in Java 21 for lower-overhead ongoing memory monitoring, and discusses using JFR event streaming to feed live data to dashboards or alerting systems.

5m read timeFrom morling.dev
Post cover image

Sort: