The runtime data area of JVM composition 2

Runtime data area: method area, heap, virtual machine stack, PC (program counter) register, local method stack
Method area and heap are shared by threads, others are private to threads

The method area stores the loaded class information (names, modifiers, etc.), static variables in the class, constants defined as final types in the class, Field information in the class, and method information in the class. When obtaining information through the methods such as getName and isInterface in the Class object, these data all come from the method area, and the method area is also shared globally. Under certain conditions, it will also be GCed. When the method area needs to use the memory When it exceeds its allowable size, an OutOfMemory error message will be thrown.

Heap memory allocation
The memory initially allocated by the JVM is specified by -Xms, and the default is 1/64 of the physical memory; the
maximum allocated memory by the JVM is specified by -Xmx, and the default is 1/4 of the physical memory.
When the default free heap memory is less than 40%, the JVM will increase the heap until the maximum limit of -Xmx; when the
free heap memory is greater than 70%, the JVM will reduce the heap until the minimum limit of -Xms.
Therefore , the server generally sets -Xms, -Xmx equal to avoid adjusting the size of the heap after each GC .
An object's heap memory is reclaimed by an automatic memory management system called the Garbage Collector (GC). 

The virtual machine stack is private to the thread. When each thread is created, a JVM stack is created. The
JVM stack stores the variables of the local basic type in the current thread (eight basic types defined in java: boolean, char, byte, short) , int, long, float, double), partial return results and Stack Frame,
objects of non-basic types only store an address pointing to the heap on the JVM stack
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325306173&siteId=291194637