Java Virtual machine

Source: Internet
Author: User

Java memory structure, partitioning, what to put in each zone

Program counter: (thread private) The current thread executes the line number indicator of the byte code, by changing the value of this counter to select the next need to execute the code of the instruction, in the program branches, loops and jumps and other processes of the control can not be separated from the indicator of this counter.

Virtual machine stacks: (Thread-private), where each method executes creates a stack frame for storing information such as local variable tables, operand stacks, dynamic links, and method exits. A method from the call to completion of the process, corresponding to the stack frame in the virtual machine stack in and out of the process. When the thread ends, the data in the virtual machine stack is automatically freed.

Local Variables table: Basic data types, object references, return addresses, local variable table locks require memory space that is already determined when the program is compiled.

Local method Stack: (Thread-private) The virtual machine stack is serviced for the execution of a Java method, while the local method stack is used for the local method lock service that the virtual machine uses.

Heap Area: (Thread-shared) The Java heap is an area shared by all threads, and all instances and arrays of objects are allocated in the heap area. Java Heap Subdivision: The new generation and the old age; It is also possible to divide multiple thread lock share allocation buffers Tlab;

The Java heap can be in a physically discontinuous memory space, as long as it is logically contiguous.

Method Area: (thread sharing) stores information, constants, static variables, and compiled code of a timely compiler for a class that has been loaded by a virtual machine. A region in the method area is called a run-time constant pool, which holds references to literal and symbolic characters generated after compilation.

the generation of heaps

(1) Young generation:

All newly generated objects are first placed in the younger generation. The goal of the young generation is to collect as quickly as possible those objects with short life cycles. The young generation is divided into three districts. One Eden area, two survivor districts (in general).
Most objects are generated in the Eden area. When the Eden Zone is full, the surviving objects will be copied to the Survivor area (one of two), and when a survivor area is full, the surviving objects of this area will be copied to another survivor area, and when another survivor area is full, Objects that were copied from a survivor area and survived at this time will be copied "old age area (tenured)".

(2) elderly generation:

Objects that survived after N (configurable) garbage collection in the younger generation will be placed in the old age generation. Therefore, it can be considered that older generations are storing objects with longer life cycles.

(3) Lasting generations:

Used to store static data, such as Java Class, Method, and so on. Persistent generations have no significant impact on garbage collection.

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.