Java run-time data region

Source: Internet
Author: User

Java Runtime Data Region summary


Thread-Private :

Program Counter : It is a small area of memory that can be thought of as the line number indicator of the bytecode executed by the current thread. If the thread is executing a Java method, this counter records the address of the executing virtual machine bytecode instruction, or null if the native method is being executed. Note: This memory area is the only area in the Java Virtual Machine specification that does not stipulate any outofmemoryerror conditions .

Java Virtual machine stack : Java Virtual machine stack and thread life cycle is the same, each method is called until the completion of the process, corresponding to a stack frame in the virtual machine stack from the stack to the stack process. Description of local variable table in virtual machine stack



      • The local variable table holds the various (8) basic data types and object references, ReturnAddress types (addresses that point to a bytecode directive) that are known during the compilation period.

      • The 64-bit long and double data types in the local variable table occupy 2 local variable space, the other types occupy one, the memory space required by the local variable table is allocated at compile time, and when entering a method, the method needs to allocate how much local variable space in the frame is fully determined, The size of the local variable table is not changed while the method is running.

Local method Stack : The local method stack is a service to the native method used by the virtual machine, and it is similar to the Java Virtual machine stack, except that the service object is different.




non-thread-private :

java heap: the Java heap (Java heap) is the largest piece of memory managed by a Java virtual machine. It is an area that is shared by all threads and created when the virtual machine is started. The only purpose of the Java heap is to hold object instances, where almost all object instances are stored. Java heap can be divided into the new generation and the old age, and the Cenozoic contains Eden space, from Survivor space, to survivor space. The purpose of memory partitioning is to better reclaim memory.

Method Area : The method area stores data such as class information, constants, static variables, and immediately compiled code that have been loaded by the virtual machine. It is non-heap (not heap) ( Note: Because the design team of the hotspot virtual machine chooses to extend the GC generational collection to the method area, or to use a permanent generation to implement the method area, there is no concept of a permanent generation for other virtual machines ). This area recovery target is mainly for the recovery of the constant pool (discard constant) and the unloading of the type (useless Class), but its recovery effect is very difficult to satisfy, and when the method area is unable to satisfy the memory allocation, the OutOfMemoryError exception is thrown.

run a constant pool : It is part of the method area and is used to hold various literal and symbolic references generated during the compilation period, which is dynamic, such as the possibility of putting new constants into the pool during run time, and using the Intern () method of the string class to put the string variable values into a constant pool. Running a constant pool as part of the method area is constrained by the memory of the method area, and throws a OutOfMemoryError exception when the const pool is no longer able to request memory. (TheIntern () method of the String class uses the description: The address of a in string a= "test" is the address of a constant pool; string b = new string ("test") B is the storage address of the variable in the Java heap; b = B.intern (); Represents storing the value of B as the address of a string variable in a constant pool )

Direct Memory : It is not part of the data area when the virtual runtime is running. To avoid copying data back and forth in the Java heap and the native heap, new NIO classes were added to JDK1.4, introducing channel-and buffer-based I/O, which can be used to directly allocate out-of-heap memory using the native library. It is then manipulated by a Directbybuffer object stored in the Java heap as a reference to this memory.


Object Access Description

The main access way to access objects: using a handle (containing the object's instance data and type data specific address information, the advantage is that the handle is stored in a stable handle address) and a direct pointer (object address, the advantage is that access to objects fast, it is the most widely used).



Bibliography "In-depth understanding of Java virtual machines, author Zhou Zhiming"

Java Runtime data region

Related Article

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.