Java memory Area-in-depth understanding of JVM reading notes

Source: Internet
Author: User

This content by "in-depth understanding Java Virtual Machine" part of the Reading notes collated, the reader plan serial.

Learn the concepts of several run-time data areas, such as and text introductions.

method Area: It is the area shared by each thread for data such as class information, constants, static variables, and code compiled by the immediate compiler that the memory has been loaded by the VM. The JVM specification has a loose limit on this area, as the heap does not require contiguous memory, selectable fixed size, expandable size, and optionally does not implement garbage collection. Because garbage collection is not necessary and ineffective in some areas. If recycling is also a constant pool of recycling and type unloading, this operation is unusually difficult. The OutOfMemoryError is thrown when the method area cannot satisfy the allocation of memory.

java heap: It is the memory that is shared by the largest piece of thread that is managed in the VM. Its only purpose is to store objects. The JVM specification describes all objects and arrays to be stored here. But because of the development of technology is not absolute. It is also the most important area of garbage collector management. Can be divided into: The new generation and the old age and other divisions, so that the purpose is to facilitate the division and recovery of memory. The JVM specification describes an area that can be physically discontinuous but logically contiguous. If the dump can no longer be expanded, throw outofmemoryerror.

Java Virtual machine stack: its life is the same as the thread, because it is the memory model that describes the Java method, and each method is executed to create a stack frame for storing local variable tables, operation stacks, dynamic links, method exits and other information. Each method from start execution to execution completion is a stack frame in the virtual stack into the stack into the process. There are two anomalies in some areas: if the thread request stack tries to be larger than the virtual machine allows, Stackoverflowerror will be thrown, and if the VM can be dynamically scaled, the outofmemoryerror may be thrown when the extension fails to request enough memory.

Local method Stack: It is similar to the Java Virtual machine stack, except that the virtual machine stack executes Java method services for the virtual machine, while the local method stack is the native method service used by the virtual machine. The language, manner, and data structure of the methods used in the virtual machine specification are not mandatory, and the virtual machines are free to implement it, such as Sun HotSpot directly to the local method stack and virtual machine stack. The exception thrown is the same as the virtual machine.

Program Counter : is a small memory space that acts as a line number indicator of the bytecode that is being executed by the current thread. Because the multithreading of the JVM is implemented in a way that threads take turns switching and allocating processor execution time, at any one time a processor executes only the instructions in one thread. Because the thread can be switched back to the correct execution location, each thread must have a separate program counter.

Java memory Area-in-depth understanding of JVM reading notes

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.