first, the memory structure diagram
Program counter
Saves the memory address of the virtual machine bytecode instruction executed by the current thread, allowing the thread to return to its original state when it is switched back. (The counter is empty if the local native is rich)
Virtual machine stack (JVM stack)
A Java stack is created each time a thread is created, so the Java stack is also a "thread-private" memory area, which in turn contains multiple stack frames, and each time a method is called, a stack frame is created and pressed into the stack . Stack frames are data structures used to store method data and partial process results, each of which is a process from the call to the final return result, corresponding to a stack frame from the stack to the stack.
We usually say the stack stack, the stack refers to the JVM stack, the heap is explained below.
Local method Stack
Similar to the virtual machine stack, serves the local method.
Method area
Used to store data such as class information, constants, static variables, and code compiled by the immediate compiler that have been loaded by the virtual machine.
There is also a constant pool in the method area, and the constant pool contains constants and symbolic references (the parsing process in the join phase of the load class converts the symbolic reference to a direct reference).
Heap
A heap is a place where a Java instance or object is stored, a primary area of the GC, and also a memory area shared by the thread. (further subdivided into the new generation and the old age )
second, control parameters
-XMS Sets the minimum space size for the heap. -XMX sets the maximum space size for the heap. -xx:newsize set the Cenozoic minimum space size. -xx:maxnewsize sets the maximum space size of the Cenozoic. -Xx:permsize Set the minimum space size for the permanent generation. -xx:maxpermsize set the maximum space size for the permanent generation. -XSS Sets the stack size for each thread.
Java Foundation--JVM Memory structure