当前位置:网站首页>[JVM] - memory partition in JVM
[JVM] - memory partition in JVM
2022-06-28 05:18:00 【Classmate pan】
List of articles
JVM Partition of memory area in
JVM After startup, a large memory area will be requested from the operating system , And then you need to do it according to the function , Divide this memory into different small areas .
One java In progress , May contain multiple threads , Between multiple threads , Share the same heap and method area , But each thread has its own stack and program counters ; Each process has its own heap , Multiple processes are not shared
Program counter
It is the smallest area in memory : It saves the address of the next instruction to be executed by the current thread
Instructions , That is to say Bytecode , The program wants to run ,JVM You have to load the bytecode , Put it in memory , The program will take instructions out of memory one by one , Put it in CPU On the implementation , You need to keep in mind which one you are currently executing . This is because CPU It is a parallel program , It doesn't just serve one process , Serve all processes .( This is equivalent to when we usually read , Which page did you see last , Just put the bookmark on that page , So that we can start from that page next time )
Because the operating system schedules the execution in the unit of threads , Each thread has to record its execution location , therefore The program counter is one for each thread .
Stack
What's inside is mainly Local variables and method call information
When the method is called , Each time a new method is called , It all involves “ Push ” operation ; One method at a time , It's all about “ Out of the stack ” operation .
Be careful : The stack space is actually small , Although in JVM The size of stack space can be configured in , But usually it is just a few M Or dozens M, So the stack is likely to be full . Write code normally , Generally nothing , Afraid of recursion , And the recursion condition is not set well , Then directly Stack overflow 了 StackOverflowException
Every thread has a stack
Pile up
There is only one copy of a process , Multiple threads share a heap , It is also the largest area in memory
new Out object , It's in the pile , Then the member variables of the object are naturally in the heap
Here we need to distinguish one thing that is easy to confuse :
Variables of built-in type are on the stack , Variables of reference type are on the heap , Is this statement correct
The answer is incorrect , Local variables are on the stack , Member variables and new The objects of are on the heap , It doesn't matter what type of variable it is 
Method area
Method area , It's “ Class object ”.
So-called “ Class object ” Namely : What we wrote .java Such code will become .class( Binary bytecode ),.class Will be loaded into memory , It was JVM Constructed as a class object ( The loading process becomes “ Class loading ”)
There is another important thing in class objects , Static members —— By static Decorated member , Become “ Class properties ”, And ordinary members , be called “ Instance attributes ”
The class object describes what the class looks like : What is the name of the class , Who's in it , What are the methods , What is the name and type of each member , yes public/private, What is the name and type of each method , yes public/private, Methods, etc
边栏推荐
- Prove that there are infinite primes / primes
- 店铺进销存管理系统源码
- Study on modified triphosphate: lumiprobe amino-11-ddutp
- Quartus replication IP core
- 开关电源电压型与电流型控制
- Learn Taiji Maker - mqtt Chapter 2 (IV) esp8266 reserved message application
- quartus 复制IP核
- Hundreds of lines of code to implement a script interpreter
- Sorting out some topics of modern exchange principle MOOC
- MCLK configuration of Qualcomm platform camera
猜你喜欢

2022 safety officer-b certificate examination question bank and answers

quartus 复制IP核

wordpress zibll子比主题6.4.1开心版 免授权
![[leetcode] 12. Integer to Roman numeral](/img/3e/815f24a85a3333ce924acee1856f62.png)
[leetcode] 12. Integer to Roman numeral

Latest Windows version 5.0.14 of redis

Leetcode 88: merge two ordered arrays

Store inventory management system source code

Deeplearning ai-week1-quiz

Feign implements path escape through custom annotations

CpG solid support research: lumiprobe general CpG type II
随机推荐
QCOM LCD调试
Qcom LCD commissioning
学习太极创客 — MQTT 第二章(五)心跳机制
Don't roll! How to reproduce a paper with high quality?
lotus v1.16.0 calibnet
禁用右击、键盘打开控制台事件
Operation of simulated examination platform of G3 boiler water treatment recurrent training question bank in 2022
How long will the PMP test results come out? You must know this!
BioVendor sRAGE蛋白解决方案
吴恩达深度学习测验题:deeplearning.ai-week1-quiz
短视频本地生活版块成为热门,如何把握新的风口机遇?
BioVendor sRAGE抗体解决方案
BioVendor sRAGE Elisa试剂盒化学性质和技术研究
109. simple chat room 12: realize client-side one-to-one chat
Steve Jobs' speech at Stanford University -- follow your heart
[JVM series] JVM tuning
Informatics Orsay all in one 1360: strange lift
Leetcode 88: merge two ordered arrays
IP datagram sending and forwarding process
学习太极创客 — MQTT 第二章(四)ESP8266 保留消息应用