"005" "Jvm--hotspot Algorithm for survival object determination and garbage collection"

Source: Internet
Author: User

The Hotspot algorithm realizes survival object judgment and garbage collection Enumerate root nodes

as a GC Roots nodes are large in number, checking the references inside, and consuming a lot of time, primarily in global references (such as Constants or class static properties) and execution contexts (such as table of local variables in a stack frame). Second, accurate accessibility analysis requires suspending the execution of threads.

current mainstream Java  The virtual machine uses the exact type gc  (accurate memory management exact memories management< Span style= "font-family: Arial" >: The virtual machine knows what the data type of a location in memory is, so when the execution system pauses, the   Hotspot    Oopmap   HotSpot  Jit  In the process of compiling, it is also possible to record in a particular location which locations in the next battle and register are references. gc  This information can be directly known at the time of scanning.

Safety Point

generated for each instruction Oopmap, consumes a lot of space, theGC cost is very high. HotSpot also does not do this, only to record this information in a particular bit, these locations are called " security points ", that is, when the program executes not all places can stop to start the GC, You can only pause when the security point is reached. The choice of a security point is selected by the criteria for whether the program has a feature that allows the program to perform for a long time . The most obvious is the instruction multiplexing, such as method invocation, loop jump.

How do I get all the threads (not including the Jni  called thread) all "  run "  preemptive suspension   voluntary Suspension )

    • preemptive interrupt: Do not require thread execution code to actively mate, in gc  " run " to the safe point.   There is now virtually no virtual machine implementation.

    • active interrupt: When gc

The polling flag is coincident with the security point, plus the place where the object needs to be allocated memory.

Security Zone

the homicide point solved how to get into GC problem, the problem still exists, if the thread is in a sleep state or blocking state, at this time the thread cannot respond to the JVM 's interrupt request, cannot " go " to a safe place to break the hang. It is also impossible for the JVM to wait for threads to be allocated CPU time again. This will require a secure zone (safe region ) to resolve.

Security Zone : Refers to a code fragment where the reference relationship does not change. It is safe to start a GC anywhere in the region , and the security zone can be seen as a security point that has been expanded. When a thread executes code in a security zone, it first identifies itself as having entered a security zone, during which time the JVM initiates a GC, andthe JVM does not have to control the money that is identified as a safe zone state. When a thread leaves the security zone, it checks to see if the system has completed the root node enumeration (or the entire GC process), and if it completes, the thread will continue to execute, otherwise it will have to wait until it receives a signal that it can safely leave the security zone.

"See" " Deep understanding Java Virtual Machine (second edition) "Zhou Zhiming"

" starter" "http://my.oschina.net/shiinnny/blog/388432 " "


"005" "Jvm--hotspot Algorithm for survival object determination and garbage collection"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.