当前位置:网站首页>[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
边栏推荐
猜你喜欢

PCR/qPCR研究:Lumiprobe丨dsGreen 用于实时 PCR

Quartus replication IP core

吴恩达深度学习测验题:deeplearning.ai-week1-quiz

DH parameters of robotics and derivation using MATLAB symbolic operation

How to design an awesome high concurrency architecture from scratch (recommended Collection)

Learning Tai Chi Maker - mqtt Chapter 2 (V) heartbeat mechanism

2022 safety officer-b certificate examination question bank and answers
![[JVM series] JVM tuning](/img/e1/086f76ec6c9b56d97430b1e073f5a6.png)
[JVM series] JVM tuning

!‘ Cat 'is not an internal or external command, nor is it a runnable program or batch file.

Learning Tai Chi Maker - mqtt Chapter II (VI) mqtt wills
随机推荐
DPDK 源码测试时性能下降问题
2022 high altitude installation, maintenance and removal examination questions and answers
wordpress zibll子比主题6.4.1开心版 免授权
电源插座是如何传输电的?困扰小伙伴这么多年的简单问题
Wedding studio portal applet based on wechat applet
氨基染料研究:Lumiprobe FAM 胺,6-异构体
别卷!如何高质量地复现一篇论文?
JS 文本框失去焦点修改全半角文字和符号
Function reentry caused by Keil C51's data overlaying mechanism
Binary sort tree: BST
Store inventory management system source code
无线传感器网络学习笔记(一)
Study on chemical properties and technology of biovendor rage ELISA Kit
C语言中函数是什么?编程中的函数与数学中的函数区别?理解编程语言中的函数
Assembly common instructions
Study on modified triphosphate: lumiprobe amino-11-ddutp
2022西式面点师(高级)考试试题模拟考试平台操作
程序员坐牢了,会被安排去写代码吗?
并发之wait/notify说明
QCOM LCD调试