JVM architecture-Memory model __java

Source: Internet
Author: User

One: Java technology system module diagram II: JVM Memory Area model

1. Method Area

Also known as "permanent generation", "not heap", it is used to store virtual machine loaded class information, constants, static variables, is the memory area shared by each thread. The default minimum value is 16MB and the maximum is 64MB, and the size of the method area can be limited by-xx:permsize and-xx:maxpermsize parameters.

Run a constant-amount pool: is part of the method area, in addition to the description of the version, field, method, and interface of the class file, there is also a constant pool that holds the various symbolic references generated by the compiler, which are placed in the Run-time pool of the method area after the class is loaded. 2. Virtual Machine Stack

Describes the memory model executed by the Java method: Each method is executed with the creation of a "stack frame" to store information such as local variable tables (including parameters), operation Stacks, method exits, and so on. Each method is called to the completion of the process, corresponding to a stack frame in the virtual machine stack from the stack to the process. The declaration cycle is the same as the thread, and is thread-private.

The Local variables table holds the various basic data types known to the compiler (Boolean, Byte, char, short, int, float, long, double), object reference (reference pointer, not the object itself). 64-bit long and double types of data occupy 2 local variables, and the remaining data types account for only 1. The memory space required by a local variable table is allocated during compilation, and when a method is entered, it is entirely certain that the method needs to allocate a large number of local variables in the stack frame, and the stack frame does not change the size space of the local variable table during runtime. 3. Local method Stack

Similar to the virtual machine stack, the difference is that the virtual machine stack performs Java method services for the virtual machine, while the local method stack serves the native method. 4. Heap

Also called the Java heap, the GC heap is the largest chunk of memory in the memory managed by the Java Virtual machine, and the memory area shared by each thread, created when the JVM is started. The memory area holds the object instance and the array (all new objects). Its size is set by the-XMS (minimum) and-xmx (maximum) parameters,-xms the minimum memory requested for the JVM when it is started, the default is 1/64 of the operating system's physical memory, but less than the maximum amount of memory that can be requested by the JVM, which defaults to 1/4 of physical memory but less than 1G By default, when the free heap memory is less than 40%, the JVM increases the size specified by heap to-XMX, which can be specified by-xx:minheapfreeration=, and when the free heap memory is greater than 70%, the JVM reduces the size of the heap to the size specified by the-XMS. You can specify this column by xx:maxheapfreeration=, and for running the system, to avoid frequent resizing of heap at run time, the-XMS is usually set to the same value as-XMX.

Since collectors are now using a generational collection algorithm, the heap is divided into Cenozoic and old eras. The new generation mainly stores newly created objects and objects that have not yet entered the old age. Older generations store objects that are still alive through multiple Cenozoic GC (Minor GC). New Generation:

New objects are created from the Cenozoic memory, the Cenozoic by Eden Space and two of the same size survivor space (usually also known as S0 and S1 or from and to), can be specified by the-xmn parameters of the Cenozoic size, or through the-XX: Survivorration to adjust the size of Eden space and survivor space. old age:

For storing objects that have survived multiple Cenozoic GC, such as cached objects, new objects may also go directly into the old age, there are two main situations: ①. Large objects, set-xx:pretenuresizethreshold=1024 in bytes, default to 0 by startup parameter ) to represent more than the Cenozoic distribution, but directly in the old age distribution. ②. Large Array object that does not refer to an external object in a tangent array.

The memory size of the older generation is-xmx corresponding to the value minus the-xmn corresponding value. 5. Program Counter

is the smallest piece of memory area, the function is the line number indicator of the byte code executed by the current thread, and in the model of the virtual machine, the bytecode interpreter works by changing the value of the counter to select the next byte code instruction to execute, branching, looping, exception handling, Basic functions, such as thread recovery, need to rely on counter completion. three: Direct memory

Direct memory is not part of the virtual machine memory, nor is it a memory area defined in the Java Virtual Machine specification. The newly added NiO in jdk1.4 introduces the IO method of channel and buffer, it can call the native method to allocate the outside memory directly, the heap outer memory is native memory, not affect the heap memory size.

This article is reproduced from: http://blog.csdn.net/java2000_wl/article/details/8009362

Reprint please indicate the source.

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.