Deep understanding of Java Virtual Machine-Chapter 2: deep understanding of Java Virtual Machine

Source: Internet
Author: User

Deep understanding of Java Virtual Machine-Chapter 2: deep understanding of Java Virtual Machine

Chapter 2 Java memory zone and memory overflow exceptions

Running data area

1. The Program Counter (Program Counter Register) is a small memory space, which can be seen as the row number indicator of the bytecode executed by the current thread.

2. the Java Virtual Machine Stack (Stack) thread is private. A Stack Frame is created for each method call to store information such as the local variable table, operand Stack, dynamic link, and method exit. Local variables store various basic data types (boolean, byte, char, short, int, float, long, double), object reference (reference type), and returnAddress known during the compilation period.

3. Native Method Stack (Native Method Stack): Stack provided for local methods of virtual machines

4. A memory area shared by all java Heap threads to store object instances. It may be divided into the new generation and the old generation. The details include Eden space, From other vor space, and To another vor space.

5. Each purebred shared memory Area in the Method Area is used to store data such as class information, constants, static variables, and Code Compiled by the real-time compiler. Permanent Generation)

6. The Runtime Constant Pool is part of the method area and is used to store various literal quantities and symbolic references generated during the compilation period, this part of content will be stored in the runtime pool of the method area after the class is loaded.

7. Direct Memory)

HotSpot virtual machine object discovery

Object Creation

1. Check whether the new parameter can be located in the constant pool.

2. Check whether the class represented by this symbolic reference has been loaded for parsing and initialization.

If the corresponding class loading process is not executed first.

3. allocate memory. The size of the memory required by the object can be determined after the class is loaded.

4. initialize the allocated memory space to a zero value. This step ensures that the instance field of the object can be directly used without the initial value in java code.

5. The virtual machine makes necessary settings on the object. How can we find the metadata information of the class, the hash code of the object, and the GC generation of the object? These information are stored in the object header.

6. Constructor

Object Memory layout: it can be divided into three areas: object Header, Instance Data, and Padding)

Object Access location:

Access an object through a handle

Direct pointer access to objects

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.