The graph shows the data area of the Java virtual machine in operation:

1. The method of area

Also known as “permanent generation” or “non-heap”, it is used to store information about classes loaded by the VIRTUAL machine, constants, static variables, and an area of memory shared by each thread. The default minimum value is 16MB, and the maximum value is 64MB (unverified). You can limit the size of the method area by using the -xx :PermSize and -xx :MaxPermSize parameters.

Runtime constant pool: part of the method area. In addition to the description of the Class version, fields, methods, and interfaces, the Class file contains a constant pool, which is used to store symbolic references generated by the compiler. This part of the constant pool is put into the runtime constant pool of the method area after the Class is loaded.

2. Vm stack

Describes the memory model of Java method execution: each method execution creates a “stack frame” to store information about local variables (including parameters), operation stack, method exit, and so on. Each method is called to the end of the execution process, corresponding to a stack frame in the virtual machine stack from the stack to the stack process. The declaration period is the same as the thread and is thread-private.

The local variable table stores basic data types known by the compiler (Boolean, byte, char, short, int, float, long, double), object references (referencing Pointers, not objects themselves), 64-bit longs and doubles take up space for two local variables, and only one for the rest. The memory space required for the local variable table is allocated at compile time. When entering a method, how many local variables the method needs to allocate in the stack frame is completely determined. Stack frames do not change the size space of the local variable table during runtime.

3. Local method stack

It is similar to the virtual machine stack except that the virtual machine stack serves Java methods executed by the virtual machine, while the Native method stack serves Native methods.

4. The heap

Also known as the Java heap or GC heap, it is the largest area of memory managed by the Java Virtual machine and shared by individual threads. It is created when the JVM starts. This memory area holds object instances and arrays (all new objects). The size is set by -xms (minimum) and -xmx (maximum) parameters, where -xms is the minimum memory that the JVM can request at startup and -xmx is the maximum memory that the JVM can request. When the JVM starts, the maximum memory is reserved. The address space reserved for object memory can be divided into young and old generations.

By default, when the free Heap is less than 40%, the JVM will increase the Heap to the size specified by -xmx. This can be specified by -xx :MinHeapFreeRation=. When free heap memory is greater than 70%, the JVM will reduce the heap size to the size specified by -xms. This can be specified by XX:MaxHeapFreeRation=. For running systems, to avoid frequent adjustment of the heap size at run time, -xms is usually set to the same value as -xmx.


Default Value









Starting with J2SE 1.2, the JVM uses a generational collection algorithm, using different algorithms for regions of different eras. The heap is divided into Cenozoic and old age. The new generation mainly stores newly created objects and objects that have not yet entered the old age. Old age stores objects that have survived multiple Cenozoic GC(MinorGC).

Note 1: Perm in the figure is not heap memory, but permanent generation

Note 2: Virtaul in the figure is the memory that has not been allocated for each region, i.e., maximum memory – currently allocated memory

New generation:

The New Generation includes one Eden and two survivor(commonly known as S0 and S1 or From and To). Most objects are initialized in Eden. For 2 blocks of survivor, one block is always empty and will serve as an active object in Eden and a destination for the other block of survivor during the next replication collection. Before objects become old (that is, before they are copied to Tenured), they will replicate in this way between two survivor regions. The -xmn parameter can be used to specify the size of the new generation, or the -xx :SurvivorRation parameter can be used to adjust the size of Eden Space and Survivor Space.

Old age:

It is used to store objects that have survived multiple Minor GC generations, such as cached objects, and it is possible for newly created objects to age directly. Large objects, can be set up through the launch parameters – XX: PretenureSizeThreshold = 1024 (unit for bytes, the default is 0) to represent more than how would not be in the new generation of distribution, but in old age distribution directly. ②. Large array objects, that is, there are no references to external objects in the array.

The memory size of the old years is the value of -xmx minus the value of -xmn.

5. Program counter

Is the smallest a memory area, it is the function of the current thread performed by the number of rows in the bytecode indicator, in the model of the virtual machine bytecode interpreter at work is by changing the counter value to select a need to be performed under the bytecode instruction, branch, loop, exception handling, restore the basic function such as thread are carried out to need to rely on the counter.