Java Runtime Memory Mode learning

Source: Internet
Author: User

Learn Java Runtime memory mode:

Description of each district:

Method area (thread sharing): Used to hold metadata for classes loaded by virtual machines: static variables, constants, and compiled and code (bytecode), also known as permanent generations (all instances of that class are recycled, or such classloader are recycled).

Java heap (thread sharing): Storing object instances and arrays, which is the main place for memory recycling. Can be divided into the Cenozoic (young) and the Old Generation (tenured). It can literally be known that the new generation holds the objects just created

Older generations store objects that have not been recycled by the garbage collection mechanism for a long time. The general Cenozoic is divided into Eden,from survivor and to survivor. This is the allocation associated with the recovery algorithm (configured via-XMS and-XMX).

Program counters (thread-private): Java is compiled into class and interpreted by the JVM, executing every instruction. The program counter records the bytecode address that is executed by the current thread, allowing the program to know where to execute when polling for CPU time slices execution. So it's good to think that this area is thread-private, because the execution address of different threads is recorded here. (The program counters are generally small, so the memory is ignored in the analysis of resources).

Virtual machine stacks (thread-private): Built with threads, this is the memory model for method execution, which manages the execution of methods. When the method begins execution, the method executes information such as the local variable table, the operand stack, the dynamic link method, the return value, the address of the return value, and so on. The size of the stack determines the reach depth of the method call (how many levels are recursive, or how many layers are nested to call other methods, the-XSS parameter can set the virtual machine stack size). The size of the stack can be fixed, or dynamically expanded. Throws a stackoverflowerror if the requested stack depth is greater than the maximum available depth, or throws OutOfMemoryError if the stack is dynamically extensible, but no memory space is available to support the extension.

Local method Stack (thread-private): The local method stack is similar to the virtual machine stack, except that it is a memory model for storing local methods, managing the execution of local methods (Native)

  

  

Java Runtime Memory Mode learning

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.