IBM Monitoring and Diagnostic Tools for Java - Garbage Collection and Memory Visualizer (GCMV) has been able to load, graph, and carry out leak detection for "native" memory on AIX and Linux for some time. With the newly released version 2.3, it will now also do so for Windows as well!
What is "native" memory and why monitor it?
Java applications run in a virtualized Java Runtime Environment (JRE), which provides the Java heap that is commonly associated with Java memory usage as it is where Java objects are created and managed for the application.
The JRE process itself is a native process running on the Operating System (OS), in the same way as any other native process would. As such it consumes native resources, including memory. This "native" memory consumed by the JRE process includes all of its allocations, for example: the Java Virtual Machine (JVM), Just In Time (JIT) compiled code, Java Native Interface (JNI) allocations used to back Java objects, as well as the Java heap itself.
The main reason for monitoring "native" memory usage is the same as for Java heap memory: should the available memory become exhausted, an OutOfMemoryError will be generated. In addition, it's useful for understanding whether of not it's possible to increase the Java heap size should you want to. As the Java heap is one of the constituent parts of the native memory usage, increasing the Java heap size will increase the native heap usage and will lead to an OutOfMemoryError due to native heap exhaustion if it is increased to the point that the native memory usage exceeds the limit of what is available.
An excellent discussion on this topic, which includes what the OS memory limits are, is available from Andrew Hall's article "Thanks for the memory"on developerWorks.
Monitoring native memory usage in GCMV
GCMV can load and parse native memory usage data generated using svmon on AIX, ps on Linux and perfmon on Windows. Full instructions on how to generate the data are provided in the "Help" information provided by GCMV in ISA in the following section:
Tool: IBM Monitoring and Diagnostic Tools for Java - Garbage Collection and Memory Visualizer > Using Garbage Collection and Memory Visualizer > Supported data types > Native memory
Once loaded in to GCMV, the memory usage data is available as raw, structured and tabbed data, graphed to produce a line plot, and a report provided that does statistical analysis and looks for potential memory leaks.
You may have realised that, as GCMV is graphing native memory, it's not specific to Java applications so can be used for any process. In fact, the output above is from the web browser running on my desktop.