Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Name the main categories of non-heap memory a JVM uses, which native memory tracking reports separately.

Besides the Java heap, a JVM uses native memory for several separate purposes, and native memory tracking reports each as its own category: Class for metaspace and class metadata, Thread for thread stacks and per-thread data, Code for the JIT code cache, GC for the collector's own data structures such as remembered sets and mark bitmaps, and Internal and Other for JVM internal allocations and, among others, direct buffers. There are also smaller categories such as Compiler, Symbol and Arena Chunk, and the exact names vary between JDK versions.

Why this question is asked

Many engineers think of JVM memory as the heap and nothing else, then are surprised when a container with a 1 GB heap uses 1.6 GB of memory. The difference is native memory, and it is the reason containers get OOM killed while heap dashboards look healthy. Interviewers ask this question to check that we know where the extra memory goes, because sizing containers and investigating memory problems depends on it. In this answer, we will recap what native memory tracking is, go through each main category with what it holds and what makes it grow, and see what a summary looks like.

1A Quick Recap of Native Memory Tracking

Native memory is memory the JVM allocates directly from the operating system, outside the Java heap, through malloc or by mapping memory regions. Our Java objects do not live there, but the JVM's own machinery does.

Native memory tracking, NMT, is a HotSpot feature that records these allocations by purpose. We enable it at startup with -XX:NativeMemoryTracking=summary, and then jcmd <pid> VM.native_memory summary prints, for each category, how much memory is reserved, meaning address space set aside, and how much is committed, meaning actually backed by memory. Committed is the number that roughly corresponds to what the process uses.

Shell
java -XX:NativeMemoryTracking=summary -Xmx1g -jar orders.jar
jcmd 4121 VM.native_memory summary
# Total: reserved=2.7GB, committed=1.4GB
# - Java Heap (reserved=1024MB, committed=1024MB)
# - Class (reserved=1060MB, committed=95MB) (classes #18,400)
# - Thread (reserved=210MB, committed=26MB) (thread #205)
# - Code (reserved=245MB, committed=48MB)
# - GC (reserved=60MB, committed=60MB)
# - Internal (reserved=4MB, committed=4MB)
# - Other (reserved=130MB, committed=130MB)
# (example output, shortened; layout and categories differ by JDK version)

In this example the heap is 1 GB, and the other categories add about 360 MB committed. That is the gap between heap size and process memory that surprises people. Let us go through the categories one by one.

2Class: Metaspace and Class Metadata

Every class the JVM loads needs metadata: its methods, fields, constant pool, bytecode and the JVM's internal representation of it. Since Java 8 this lives in metaspace, in native memory, and NMT reports it under Class. With compressed class pointers, which are on by default, part of it is a separate compressed class space, which explains the large reserved figure, often around 1 GB, while only a small part is committed.

Class memory grows with the number of loaded classes. A Spring Boot service with many dependencies often loads 15,000 to 30,000 classes and uses 80 to 200 MB here. Continuous growth means classes are loaded and never unloaded, typically a class loader leak or runtime code generation, and can end in OutOfMemoryError: Metaspace.

3Thread: Stacks and Per-Thread Data

Every platform thread has a native stack for its method frames and some JVM bookkeeping. On 64-bit Linux the default stack size is 1 MB, set with -Xss, but that is reserved address space; only the pages the thread actually touches are committed. So 200 threads reserve about 200 MB but may commit only 20 to 40 MB, as in the example.

Thread memory grows with the number of threads. A service that creates a new thread pool per request, or has thousands of threads blocked on slow I/O, can use hundreds of megabytes here. Virtual threads are different: their stacks live on the heap as objects, so they do not appear in this category the same way.

4Code: the JIT Code Cache

The JIT compiler turns frequently run bytecode into machine code and stores it in the code cache. With tiered compilation, the default, the maximum size is about 240 MB, set with -XX:ReservedCodeCacheSize, and it is split into segments for different kinds of code.

A typical service commits 30 to 100 MB here, growing during warmup and then levelling off. If it fills up completely, the JVM logs a warning that the code cache is full and stops compiling new code, and performance drops because new hot code stays interpreted.

5GC: Collector Data Structures

The garbage collector needs its own bookkeeping, separate from the heap it manages. G1, the default collector, keeps remembered sets, which record references between heap regions so a region can be collected without scanning the whole heap, mark bitmaps for marking live objects, and other structures. These typically use a few percent of the heap size, more for heaps with many cross-region references.

So the GC category scales with heap size and with the collector chosen. Serial and Parallel collectors need less; G1 and ZGC need more. When we double the heap, this category grows too, which is one reason a larger heap needs a larger container limit than the heap increase alone.

6Internal, Other and the Smaller Categories

Internal covers various JVM internal allocations, such as data used by the JVM's own command handling and some tooling support. Other is a broad bucket that includes memory allocated through Unsafe.allocateMemory, which is how direct ByteBuffers get their native memory. So when an application or a library such as Netty uses many direct buffers, the growth usually shows up in Other, and its limit is controlled by -XX:MaxDirectMemorySize.

There are several smaller categories. Compiler holds the JIT compiler's working memory during compilations, which can spike briefly. Symbol holds the JVM's symbol table, the interned names of classes, methods and signatures. Arena Chunk is memory for short-lived internal arenas. Recent JDKs also report categories such as Metaspace, Shared class space for class data sharing, Synchronizer and Serviceability separately. The exact set and names change between JDK versions, so we check the output of our own version rather than relying on a fixed list.

Main NMT categories
CategoryHoldsGrows with
Java Heapour objects-Xmx or MaxRAMPercentage
Classmetaspace, class metadatanumber of loaded classes
Threadthread stacks, per-thread datanumber of platform threads
CodeJIT code cacheamount of compiled code
GCremembered sets, mark bitmapsheap size and collector
CompilerJIT working memorycompilations in progress
InternalJVM internal allocationsvaries
Otherincludes direct buffersdirect ByteBuffer use
Symbolclass and method namesnumber of classes
Names and the exact list vary by JDK version.

7Follow-up questions

Why is reserved so much bigger than committed for Class and Thread?

Because the JVM reserves address space up front for the maximum it might need, such as about 1 GB of compressed class space and 1 MB per thread stack, but only commits pages as they are used. Reserved address space costs almost nothing on 64-bit systems; committed memory is what counts toward the process's memory use.

Does NMT see everything the process uses?

No. It tracks the JVM's own allocations. Memory allocated by native libraries through their own malloc calls, for example a compression or database library used through JNI, and fragmentation inside the C allocator are not attributed to these categories, so resident memory can exceed NMT's committed total.

8Conclusion

In this answer, we went through the categories that native memory tracking reports besides the Java heap. Class holds metaspace and class metadata and grows with loaded classes, Thread holds thread stacks and grows with platform threads, Code is the JIT code cache, GC holds the collector's remembered sets and mark bitmaps and grows with the heap, and Internal and Other hold JVM internal allocations and direct buffers among others. Smaller categories such as Compiler, Symbol and Arena Chunk complete the picture, and the exact names vary by JDK version.

What to say in the interviewAbout 80 seconds aloud

Open with

Native memory tracking splits the JVM's memory outside the heap into categories, and the main ones are these. Class is metaspace, the class metadata for every loaded class; a Spring Boot service with 20,000 classes might commit 100 to 200 megabytes there, and steady growth means a class loader leak.

Then, if they want more

Thread is thread stacks and per-thread data; each platform thread reserves about a megabyte of stack by default but commits only what it touches, so it grows with the thread count. Code is the JIT code cache, up to about 240 megabytes with tiered compilation, usually 30 to 100 committed.

GC is the collector's own structures, like G1's remembered sets and mark bitmaps, which scale with heap size. Internal is JVM internal allocations, and Other includes direct buffers allocated through Unsafe, so Netty or NIO buffer growth shows up there.

There are smaller ones like Compiler for JIT working memory, Symbol for the symbol table and Arena Chunk, and recent JDKs show Metaspace and shared class space separately. The names vary by version, so I check the actual output. I enable it with NativeMemoryTracking=summary and read it with jcmd VM.native_memory summary, looking at committed rather than reserved.

About this answer

Last updated
12 November 2026
Versions it names
Java 8
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Name the main categories of non-heap memory a JVM uses, which native memory tracking...": https://scrivio-interview-library.netlify.app/java/jvm-diagnostics/f8ba3182ee/