Java from Basics (iv) Java memory mechanism

Source: Internet
Author: User

Java Memory Management: Drill down into Java memory areas

The above article for the Java Memory Management mechanism is very detailed, here we just to facilitate the understanding of the later content, the Java memory mechanism to do a simple comb.

Program counter: The line number indicator of the byte code executed by the current thread, the next byte code instruction to be executed by the virtual machine, and the basic functions such as branching, looping, jumping, exception handling, thread recovery, etc., need to rely on changing the value of this counter to complete.

Stack: Saves a local variable, a reference, and is freed when the method call ends. when each method is executed, a stack frame is created at the same time to store the local variable table, the Operation Stack, the dynamic link, the method exit

and other information. Each method is called until the completion of the process, corresponding to a stack frame in the virtual machine stack from the stack to the process of the stack. Divided into virtual machine stacks and local method stacks

Heap: Created at virtual machine startup, shared by all threads, stores object instances, and managed by the Java Garbage collector (GC) for memory release.

Method area: Used to store class information that has been loaded by the virtual machine, constants, static variables, code compiled by the immediate compiler, and so on, as well as all threads shared by the thread.

Chang (Constant Pool): Part of the method area, the Java language does not require constants to be generated only at compile time, the runtime can also put new constants into the constant pool, the string class of The Intern () method is used more than the operation of the constant number of ways to add.

Static zone: Part of the method area that stores the members of the static decoration (static variables or static decorated blocks) or global variables.

Here is the Java in-memory execution flow

:

Java from Basics (iv) Java memory mechanism

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.