In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "the principle analysis of the virtual machine stack in the Java memory model". The explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the principle analysis of the virtual machine stack in the Java memory model".
In memory, the stack is divided into two parts, one is the local method stack, which serves the Native method used by the virtual machine, the specific virtual machine can be realized freely, and the other part is the virtual machine stack, which mainly executes the Java method service for the virtual machine, so it also becomes the Java stack. This paper mainly interprets the virtual machine stack in detail.
1. Java stack is also called virtual machine stack, which is what we often call stack. The Java stack is the memory model for Java method execution.
2. Java stack stores stack frames one by one, each corresponding to a called method, including a local variable table (Local Variables), Operand stack (Operand Stack), a reference to the class to which the current method belongs (Reference to runtime constant pool), a method return address (Return Address), and some additional information. When a thread executes a method, it creates a corresponding stack frame and presses the established stack frame. When the method is executed, the stack frame is taken off the stack. Therefore, it is said that there are no recycled resources for the method.
3. The local variable scale, as its name implies, must not need to be explained. You should understand its function. It is used to store local variables in a method (including non-static variables declared in the method and function parameters). For variables of basic data types, their values are stored directly, and for variables of reference types, references to objects are stored. The size of the local variable table can be determined by the compiler, so the size of the local variable table will not change during program execution.
4. Operand stack, friends who must have studied the stack in the data structure must be familiar with the problem of expression evaluation. One of the most typical applications of the stack is to evaluate expressions. Think of the process in which a thread executes a method, which is actually the process of constantly executing statements and, in the final analysis, the process of calculation. So it can be said that all the calculation processes in the program are with the help of operands.
5. A reference to the runtime pool, because constants in the class may be needed during method execution, so there must be a reference to the runtime constant.
6. Method returns the address, and when a method is executed, it returns to the place where it was called, so a method return address must be saved in the stack frame.
7. Because each thread may be executing differently, each thread has its own Java stack that does not interfere with each other.
Thank you for reading, the above is the content of "principle analysis of virtual machine stack in Java memory model". After the study of this article, I believe you have a deeper understanding of the principle analysis of virtual machine stack in Java memory model, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.