Home  >  Article  >  Java  >  Detailed introduction to jvm java memory area

Detailed introduction to jvm java memory area

零下一度
零下一度Original
2017-06-25 09:50:431215browse
The memory area that the jvm virtual machine needs to use when running. Broadly speaking, it is the heap and stack. In fact, heap and stack are just relatively general terms. The real differences are as follows
First of all Figure 1:

In general, it is
Java’s memory model
The memory model is divided into heap memory (heap) and Method area (sometimes also called non-heap) and stack
The heap is divided into the new generation (Young) and the old generation (old/Tenured)
The new generation is divided into the default ratio of 8: 1:1 eden space, from survivor space, to survivor space
When garbage collection is performed, the surviving objects from eden and survivor from will be copied to the servivor to space
Then from and to space Interchange. (When the objects in the from area are old enough, that is, the number of times marked reaches the old level, they will go to the old generation)
The memory size setting parameters can be as follows Picture description
-XMS: The minimum space of the heap
-XMX: The maximum space of the heap
-PermSize: The minimum space of the method area
-MaxPermSize: The maximum space of the method area
-Xss: The stack space of each thread
- newSize: the minimum space of the new generation
-maxNewSize: the maximum space of the new generation
The old generation memory can be controlled by setting the upper case of the heap and the size of the new generation
Old generation memory=Heap memory-New generation memory
Stack

Program Counter                                                                                                                                                                                                                                                                ​The line number indicator of the bytecode executed by the thread. The bytecode interpreter obtains the bytecode instruction to be executed by changing the line number of the counter during work. The counter is empty when calling the native method (native)

Virtual machine stack                                                                                                                        

Thread private, memory model of java execution methodEvery method will be created when it is executed Stack frame is used to store local variables, operand stacks, dynamic links, method exits and other informationLocal variable table: basic data types, object references, long and double types occupy two local variable spaces

Every time a method is called, the parameters will be pushed onto the stack
Local method stack                                
Thread private. When calling the native method

Heap:

Heap memory                          
# Thread sharing, instance of the object And arrays are stored here

The heap is divided into the new generation and the old generationIn the generational collection algorithm, the new generation is divided into eden space, from survitor space and to survitor space). They The memory ratio between them is 8:1:1

Method area                          
Thread sharing

Stores class information and constants , static variables, and just-in-time compiled codeThere is also a runtime constant pool under the method area: storing literals and symbol references generated during compilation

Refer to the blog post
Here we will test you:
What is the class information mentioned in the article?
What are the literals and symbol references generated during compilation?

The above is the detailed content of Detailed introduction to jvm java memory area. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn