Deep understanding of Java Virtual Machines-Chapter II

Source: Internet
Author: User

2nd Java memory area and memory overflow exception

Run data region

1, program Counter Register is a small amount of memory space, it can be considered as the current thread executes the byte code of the line number indicator.

2. Java Virtual machine stack (stack) threads are private, and each method call creates a stack frame to store information such as local variable tables, operand stacks, dynamic links, method exits, and so on. Local variables hold the various basic data types (boolean,byte,char,short,int,float,long,double), object references (reference types), and returnaddress types that are known at compile time.

3. Local method Stack (Native), the stack provided for the local method of the virtual machine

4. A chunk of memory shared by all threads in the Java heap (heap) that holds object instances. May be divided into: The new generation and the old age. A little more detailed is Eden space, from Survivor space, to survivor space and so on.

5. The method area is a pure-blooded shared memory area used to store data such as class information, constants, static variables, and code compiled by the instant compiler that have been loaded by the virtual machine. Often referred to as permanent generation (Permanent Generation)

6. The runtime Constant pool is a part of the method area that holds the various literal and symbolic references generated during the compilation period, which is stored in the run-time pool of the class load backward into the method area.

7. Direct Memory

Hotspot Virtual Machine Object Quest

Object creation

1, virtual opportunity to a new point, check whether this parameter can be located in the constant pool.

2. Check whether the class represented by this symbol reference has been loaded parsing and initializing

If the corresponding class loading process is not performed first.

3, allocating memory, the size of the memory required by the object can be fully determined after the class is loaded.

4, the allocated memory space is initialized to 0 values, this step ensures that the object instance field in the Java code can not be assigned to the initial value of the direct use.

5, the virtual machine to the object to make the necessary settings, how to find the metadata information of the class, the object's hash code, the object's GC generation, etc. this information is stored in the object's object header

6. Constructor function

Memory layout of objects: can be divided into 3 blocks: Object Header (header), instance (Instance data), and aligned padding (Padding)

Object Access Location:

Accessing an object through a handle

Accessing an object over a direct pointer

Deep understanding of Java Virtual Machines-Chapter II

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.