Home > Java > javaTutorial > body text

JVM learning Java runtime data area

零下一度
Release: 2017-06-01 10:32:38
Original
1447 people have browsed it

1. Program counter

The line number indicator of the bytecode executed by the current thread.

2. Java virtual machine stack

Thread private, has the samelifecycle as the thread. Used to store local variable tables, operand stacks, dynamic linked lists, method exits and other information .

Local variable table storage content:

  • Basic data types (boolean, byte, char, short, int, float, long, double)

  • Object reference (different from symbol reference, which is stored in the constant pool)

  • returnAddress type (pointing to the address of a bytecode instruction)

64-bit long and double type data occupy 2 local variable spaces (slots), and the rest occupy 1 slot.

Two exceptions:

  • StackOverflowError: The stack depth requested by the thread > the depth allowed by the virtual machine

  • OutOfMemoryError: Unable to apply for enough memory during dynamic expansion

3. Native Method Stack

Similar to the virtual machine stack, the difference is that Native Method Stack serves Native methods, and the virtual machine stack serves Java methods.

4. Java Heap

Shared by all threads, it stores object instances and arrays.

The main area managed by the garbage collector, also called "GC Heap (Garbage Collected Heap)"

includes the new generation (Eden space, From Survivor space, To Survivor space) and the old generation.

Can divide multiple thread private allocation buffers (Thread Local Allocation Buffer, TLAB).

It can be discontinuous physically but continuous logically.

Extensible: -Xmx and -Xms controls. -Xmx maximum heap memory size, -Xms initial heap memory size.

When there is no available memory in the heap to complete the instance allocation, and it cannot be expanded anymore - OutOfMemoryError

5. Method area (alias Non-Heap)

is also all threads Shared, used to store class information, constants, static variables, code compiled by the just-in-time compiler and other data that have been loaded by the virtual machine.

is also called "Permanent Generation", but it is not essentially equivalent.

The permanent generation has an upper limit of -XX:MaxPermSize.

6. Runtime Constant Pool

is part of the method area.

7. Direct Memory

The NIO (New Input/Output) class newly added to JDK1.4 introduces a method based on channel (Channel) and buffer (Buffer) I/O method, it can use the Native function library to directly allocate off-heap memory. It is not limited by the Java heap size (-Xmx), which may cause the sum of each memory area to be greater than the physical memory limit, causing an OutOfMemoryError to occur during dynamic expansion.

Summary:

  • The three memory areas 1, 2, and 3 are private to each thread

  • 4 and 5 are

  • 6 common to all threads is part of 5

  • #7 is not part of the virtual machine runtime data area, but belongs to the virtual machine's memory area Other physical memory besides

[Related recommendations]

1. java collection framework study notes

2. Introducing two code examples for calculating java running time

3. Java transaction management learning detailed explanation JDBC sample code

The above is the detailed content of JVM learning Java runtime data area. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!