What are the runtime data areas in JVM
First look at the picture:
java related video tutorial: java course
1. Program counter (PC)
is exclusive to threads. It is a smaller piece of memory and is the line number indicator of the bytecode executed by the current thread. It is the only area in the Java virtual machine specification that does not specify OOM (OutOfMemoryError).
2. The Java virtual machine stack
is exclusive to threads. The life cycle is the same as that of threads. Is the memory model for Java method execution. Execution of each method creates a stack frame that stores local variables and operands (object references). The memory space required for local variables is allocated during compilation. So the size of the stack frame will not change.
There are two exceptions:
1) If the thread request depth is greater than the stack depth, a StackOverFlowError will be thrown.
2) If the stack cannot request enough memory when dynamically expanding, OOM will be thrown.
3. Heap
The Java heap is shared by all threads. It is created when the virtual machine is started. Stored are instances and arrays of objects. The largest memory occupied. It is divided into the new generation (Young area) and the old generation (Old area). The new generation is divided into Eden area and Servior area. The Servior area is divided into From space area and To space area. The memory ratio between Eden area and Servior area is 8:1. When the extended memory is larger than the available memory, OOM will be thrown.
4. Local method stack
The local method stack is exclusive to threads. Similar to the Java virtual machine stack, but instead of serving Java methods (bytecode), it serves native non-Java methods. StackOverFlowError and OOM will also be thrown.
5. Method area
The method area is shared by all threads. Used to store class information, constants, static variables and other data that have been loaded by the virtual machine, also known as Non-Heap. The method area is also called the "permanent generation". GC is rarely performed in this area, but it does not mean that it will not be recycled. The goal of this area recycling is mainly for the recycling of the constant pool and the unloading of types. When the memory request is larger than the actual available memory, OOM will be thrown.
Recommended articles related to java: Getting started with java
The above is the detailed content of What are the runtime data areas in JVM. For more information, please follow other related articles on the PHP Chinese website!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

This project is designed to facilitate developers to monitor multiple remote host JVMs faster. If your project is Spring boot, it is very easy to integrate. Just introduce the jar package. If it is not Spring boot, don’t be discouraged. You can quickly initialize a Spring boot program and introduce it yourself. Jar package is enough

JVM command line parameters allow you to adjust JVM behavior at a fine-grained level. The common parameters include: Set the Java heap size (-Xms, -Xmx) Set the new generation size (-Xmn) Enable the parallel garbage collector (-XX:+UseParallelGC) Reduce the memory usage of the Survivor area (-XX:-ReduceSurvivorSetInMemory) Eliminate redundancy Eliminate garbage collection (-XX:-EliminateRedundantGCs) Print garbage collection information (-XX:+PrintGC) Use the G1 garbage collector (-XX:-UseG1GC) Set the maximum garbage collection pause time (-XX:MaxGCPau

Key points and precautions for mastering JVM memory usage JVM (JavaVirtualMachine) is the environment in which Java applications run, and the most important one is the memory management of the JVM. Properly managing JVM memory can not only improve application performance, but also avoid problems such as memory leaks and memory overflows. This article will introduce the key points and considerations of JVM memory usage and provide some specific code examples. JVM memory partitions JVM memory is mainly divided into the following areas: Heap (He

Java is a popular programming language. During the development of Java applications, you may encounter JVM memory overflow errors. This error usually causes the application to crash, affecting the user experience. This article will explore the causes of JVM memory overflow errors and how to deal with and avoid such errors. What is JVM memory overflow error? The Java Virtual Machine (JVM) is the running environment for Java applications. In the JVM, memory is divided into multiple areas, including heap, method area, stack, etc. The heap is used to store created objects

An introduction to the analysis of the functions and principles of the JVM virtual machine: The JVM (JavaVirtualMachine) virtual machine is one of the core components of the Java programming language, and it is one of the biggest selling points of Java. The role of the JVM is to compile Java source code into bytecodes and be responsible for executing these bytecodes. This article will introduce the role of JVM and how it works, and provide some code examples to help readers understand better. Function: The main function of JVM is to solve the problem of portability of Java programs on different platforms.

JVM memory parameter settings: How to reasonably adjust the heap memory size? In Java applications, the JVM is the key component responsible for managing memory. Among them, heap memory is used to store object instances. The size setting of heap memory has an important impact on the performance and stability of the application. This article will introduce how to reasonably adjust the heap memory size, with specific code examples. First, we need to understand some basic knowledge about JVM memory. The JVM's memory is divided into several areas, including heap memory, stack memory, method area, etc. in

Before writing a java program to check whether the JVM is 32-bit or 64-bit, let us first discuss about the JVM. JVM is a java virtual machine, responsible for executing bytecode. It is part of the Java Runtime Environment (JRE). We all know that java is platform independent, but JVM is platform dependent. We need separate JVM for each operating system. If we have the bytecode of any java source code, we can easily run it on any platform due to JVM. The entire process of java file execution is as follows - First, we save the java source code with .java extension and the compiler converts it into bytecode with .class extension. This happens at compile time. Now, at runtime, J

Detailed explanation of JVM principles: In-depth exploration of the working principle of the Java virtual machine requires specific code examples 1. Introduction With the rapid development and widespread application of the Java programming language, the Java Virtual Machine (JavaVirtualMachine, referred to as JVM) has also become indispensable in software development. a part of. As the running environment for Java programs, JVM can provide cross-platform features, allowing Java programs to run on different operating systems. In this article, we will delve into how the JVM works
