Escape analysis of Java Virtual machine

Source: Internet
Author: User

Escape analysis is an analytical technique that provides the basis for other optimization methods, and its basic behavior is to analyze the object's dynamic scope: When an object is defined in a method, it may be referenced by an external method, such as a call parameter passed to another method, called a method escape. It is even possible to be accessed by external threads, such as assignment to class variables or instance variables that can be accessed in other threads, called thread escapes.
If you can prove that an object does not escape to a method or thread, that is, other methods or threads can not access the object in any way, it is possible for this variable to do some optimization of the university.
1) on the stack allocation, if you determine that an object does not escape out of the method, then the object is allocated on the stack memory, the object occupied by the memory space can be destroyed with the stack frame stack. In general applications, the proportion of local objects that do not escape is very large, and if you can use the allocation on the stack, then the object will be automatically destroyed as the method ends, and the pressure on the garbage collection system will be much smaller.
2) Synchronous elimination, thread synchronization itself is a relatively time-consuming process, if the escape analysis can determine that a variable does not escape the thread, can not be accessed by other threads, then this variable read and write certainly will not have competition, the implementation of this variable can be eliminated.
3) scalar substitution: If the escape analysis proves that an object is not being accessed externally. And this object can be torn apart, the program actually executes the time may not create this object, and instead of directly create a number of it is used by the method of the member variable to replace.

Escape analysis of Java Virtual machine

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.