Deep understanding of Java Virtual Machine Learning notes (1)

Source: Internet
Author: User
Tags exit in

Program

Java runtime data zone:

A. Method Area ----------- (common threads)

B. Heap --------- (threads in total)

C. Virtual Machine stack --------- (thread private)

D. Local method stack ----------- (thread private)

E.ProgramCounter ----------- (thread private)

Note:

A. The thread is private. That is to say, each thread has a zone such as C, D, and E, so that it is not affected during running of each thread.

B. the life cycle of the private data zone of the thread is the same as that of the thread.

 

Virtual Machine Stack

This stack executes the Java method (bytecode) service for virtual machines. Each method creates a stack frame for storage at the same time.Local variable table(This table stores basic data types and object reference types. Lang and double occupy two local variable spaces, and the rest occupy one space), Operand stack, dynamic link, method exitAnd other information

In fact, method execution is the process of stack frame entry and exit in the Virtual Machine stack.

(Note: Generally, the stack refers to the Virtual Machine stack, which is definitely part of the local variable table in the Virtual Machine)

There are two exceptions in this region: stackoverflowerror and outofmemoryerror.

Heap

When a virtual machine is created at startup, the only object storage instance exists,Almost allObjects are allocated in this region, which is the main work zone of GC.

Method Area

Storage Class information, constants, static variables, and other data. The main goal of GC in this area is to recycle the constant pool and unload the type.

 

At the same time, note that the region has a "RunTime volume pool", which is used to store various literal variables and symbol references generated during the compilation period. An important feature of the pool is dynamic. That is to say, Java does not require constants to be generated only during compilation. New constants can also be placed in the pool during runtime, the typical method is the intern () method of the string class.

For example: "helloworld". Intern (), the returned result is still Hello world, but this method will check whether the string "Hello World" exists in the string pool. If yes, a reference to this string is returned. Otherwise, the string is put into the pool (note: this is the work completed during the runtime, not during the compilation period), and the reference of this string is returned.

Note that,UseNewThe string created by the keyword is not put into the string pool, and it has its own address space.

Exception that can be thrown: outofmemoryerror

 

 

 

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.