当前位置:网站首页>JVM memory structure
JVM memory structure
2022-06-25 16:44:00 【Zhangzhiming (autumn recruit version)】

1. Which parts of the memory will overflow
① No memory overflow area - Program counter
② There are two types of memory overflows
Ⅰ appear OutOfMemoryError The situation of
1️⃣ Heap memory exhausted - More and more objects , Has been using , Can't be recycled
2️⃣ Method area out of memory - More and more classes are loaded , Many frameworks dynamically generate new classes during runtime
3️⃣ Virtual machine stack accumulation - Each thread will occupy up to 1M Memory , When there are more and more threads running for a long time without destroying
Ⅱ appear StackOverflowError Region
1️⃣ Inside the virtual machine stack - Too many method calls ( Recursion has no proper exit )
since Java The garbage collection mechanism can automatically reclaim memory , How can there be a memory leak ?
This problem , We need to know GC When to recycle memory objects , What kind of memory object will be GC Think it's “ No longer use ” Of .
Java Access to memory objects in , It's a way of quoting . stay Java In the code, we maintain a reference variable of the memory object , Through this reference variable's value , We can access the memory object space in the corresponding memory address . stay Java In the program , The reference variable itself can be stored in heap memory , It can also be placed in the memory of the code stack ( Same as basic data type ). GC The thread will start tracking from the reference variable in the code stack , To determine which memory is in use . If GC In this way, threads , Unable to trace to a certain heap memory , that GC I think this memory will no longer be used ( Because the code can no longer access this memory ).
Through this directed graph memory management , When a memory object loses all references ,GC You can recycle it . On the other hand , If there is a reference to this object , Then it will not be GC Recycling , Even if it is Java Virtual machine throw OutOfMemoryError .
java Since it exists gc Threads , Why is there a memory leak ? - THISISPAN - Blog Garden 1. since Java The garbage collection mechanism can automatically reclaim memory , How can there be a memory leak ? This problem , We need to know GC When to recycle memory objects , What kind of memory object will be GC Think it's “ No longer use ” Of . Java in https://www.cnblogs.com/panxuejun/p/5888817.html
Method area and permanent generation 、 The relationship between meta spaces
① The method area is JVM A block in the memory specification , Used to store class metadata 、 Method bytecode
Even if the compiler
② Permanent generation is Hotspot Virtual machines are right JVM Specification implementation (1.8 Before )
③ Metaspace is Hotspot Virtual machines are right JVM Specification implementation (1.8 after ), Use local memory
As a storage space for this information
JVM Memory parameters
about JVM Memory configuration parameters : -Xmx10240m -Xms10240m -Xmn5120m -XX:SurvivorRatio=3
Where the minimum memory value and Survivor The total size is
-Xmx:jvm Maximum number of memory 1024m:10g
-Xms:jvm Minimum memory for 1024m:10g
-Xms:jvm The number of new generation memory 5120m:5g
-XX:SurvivorRatio=3 eden:from=3 So the Cenozoic is divided into 5 Share eden3 from1 to1
therefore Survivor:2g 


边栏推荐
- Bypass technology to talk about 'cross end'
- Bugly hot update usage
- 2021, committed to better development
- 数字经济时代文化消费新特征
- Android修行手册之Kotlin - 自定义View的几种写法
- DDD概念复杂难懂,实际落地如何设计代码实现模型?
- What can one line of code do?
- Collection overview, array encapsulation
- This article will help you understand the common concepts, advantages and disadvantages of JWT
- Learning notes of rxjs takeuntil operator
猜你喜欢
随机推荐
3. conditional probability and independence
cmd。。。。。。
Wireshark网卡无法找到或没有显示的问题
Bombard the headquarters. Don't let a UI framework destroy you
_ 17 collection overview
万卷书 - 大力娃的书单
What can one line of code do?
What exactly is a handler
3.条件概率与独立性
The first day of reading mysql45
DOM event flow, event delegate
Reading mysql45 lecture - index continued
Day21 multithreading
How to view the change trend of cloud database from the behind of the launch of tidb to Alibaba cloud
Read mysql45 - a simple understanding of global locks and table locks
ncnn源码学习全集
JVM内存结构
Optimization of lazyagg query rewriting in parsing data warehouse
Unity技术手册 - 生命周期旋转RotationOverLifetime-速度旋转RotationBySpeed-外力ExternalForces
[proficient in high concurrency] deeply understand the basics of assembly language









