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!

Java is widely used in enterprise-level applications because of its platform independence. 1) Platform independence is implemented through Java virtual machine (JVM), so that the code can run on any platform that supports Java. 2) It simplifies cross-platform deployment and development processes, providing greater flexibility and scalability. 3) However, it is necessary to pay attention to performance differences and third-party library compatibility and adopt best practices such as using pure Java code and cross-platform testing.

JavaplaysasignificantroleinIoTduetoitsplatformindependence.1)Itallowscodetobewrittenonceandrunonvariousdevices.2)Java'secosystemprovidesusefullibrariesforIoT.3)ItssecurityfeaturesenhanceIoTsystemsafety.However,developersmustaddressmemoryandstartuptim

ThesolutiontohandlefilepathsacrossWindowsandLinuxinJavaistousePaths.get()fromthejava.nio.filepackage.1)UsePaths.get()withSystem.getProperty("user.dir")andtherelativepathtoconstructthefilepath.2)ConverttheresultingPathobjecttoaFileobjectifne

Java'splatformindependenceissignificantbecauseitallowsdeveloperstowritecodeonceandrunitonanyplatformwithaJVM.This"writeonce,runanywhere"(WORA)approachoffers:1)Cross-platformcompatibility,enablingdeploymentacrossdifferentOSwithoutissues;2)Re

Java is suitable for developing cross-server web applications. 1) Java's "write once, run everywhere" philosophy makes its code run on any platform that supports JVM. 2) Java has a rich ecosystem, including tools such as Spring and Hibernate, to simplify the development process. 3) Java performs excellently in performance and security, providing efficient memory management and strong security guarantees.

JVM implements the WORA features of Java through bytecode interpretation, platform-independent APIs and dynamic class loading: 1. Bytecode is interpreted as machine code to ensure cross-platform operation; 2. Standard API abstract operating system differences; 3. Classes are loaded dynamically at runtime to ensure consistency.

The latest version of Java effectively solves platform-specific problems through JVM optimization, standard library improvements and third-party library support. 1) JVM optimization, such as Java11's ZGC improves garbage collection performance. 2) Standard library improvements, such as Java9's module system reducing platform-related problems. 3) Third-party libraries provide platform-optimized versions, such as OpenCV.

The JVM's bytecode verification process includes four key steps: 1) Check whether the class file format complies with the specifications, 2) Verify the validity and correctness of the bytecode instructions, 3) Perform data flow analysis to ensure type safety, and 4) Balancing the thoroughness and performance of verification. Through these steps, the JVM ensures that only secure, correct bytecode is executed, thereby protecting the integrity and security of the program.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
