650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/49/05/wKioL1QNO6izzer8AAESnZt2VL0446.jpg "Title =" image 1.jpg "alt =" wkiol1qno6izzer8aaesnzt2vl0446.jpg "/>
JVM Virtual Machine Stack: one is unique to a thread. Every time a thread is started, a JVM Virtual Machine stack is created and destroyed when the thread exits. This mainly stores the local variable name and local variable value of the thread.
Local method Stack: created when the local JNI method is called. Memory space outside JVM allocated here. Destroy a method after it is called.
PC register: This saves the bytecode instruction currently executed by the thread
Heap: stores the created objects.
Method Area: stores class-related information. It mainly refers to a memory structure information of the class.
Constant pool: A Part Of The method area. It mainly stores the values of the class memory structure, such as the string value and the public static final type.
The garbage collection mentioned here is mainly the collection of heap memory areas by Java virtual machines..
1. The first question is: how does JVM know which objects need to be recycled?
There are currently two algorithms
· Reference counting method
· Root search algorithm
The following objects are considered as root objects:
· Classes loaded and created objects by the bootstrap loader
· Objects referenced by static variables in the Method Area During JVM Runtime
· The JVM runtime method removes the objects referenced by the constant pool
· Objects referenced by the VM stack variable table in the current JVM running thread
· Objects referenced by (JNI) in the local method Stack
Basically, there are three basic algorithms for JVM memory reclaim.
· Mark-clear
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/49/05/wKioL1QNPYCifbu2AADQXgmMPyE564.jpg "style =" float: none; "Title =" image 2.jpg "alt =" wkiol1qnpycifbu2aadqxgmmp ye564.jpg "/>
· Mark-clear-compression
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/49/05/wKioL1QNPYKCEbjCAADK-yP1ZQ8824.jpg "style =" float: none; "Title =" image 3.jpg "alt =" wKioL1QNPYKCEbjCAADK-yP1ZQ8824.jpg "/>
· Mark-clear-copy
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/49/03/wKiom1QNPXiQBfFHAAEBWxkdXBU281.jpg "style =" float: none; "Title =" image 4.jpg "alt =" wkiom1qnpxiqbffhaaebwxkdxbu281.jpg "/>
This article from "android development" blog, please be sure to keep this source http://9238253.blog.51cto.com/9228253/1549890
JVM garbage collection mechanism