当前位置:网站首页>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 


边栏推荐
猜你喜欢
随机推荐
Android修行手册之Kotlin - 自定义View的几种写法
Servlet details
Catheon gaming appointed mark Aubrey, former Asia Pacific head of Activision Blizzard, as CEO
Paper notes: generalized random forests
Optimization of lazyagg query rewriting in parsing data warehouse
Day_ 16 set
20省市公布元宇宙路线图
Creating a uniapp project using hbuilder x
APIJSON简单使用
Flutter assembly
What exactly is a handler
Read AFN through - from the creation of manager to the completion of data parsing
Day_ thirteen
error Parsing error: Unexpected reserved word ‘await‘.
【蓝桥杯集训100题】scratch指令移动 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第14题
Error: homebrew core is a shallow clone
XML usage and parsing of data storage and transmission files
[proficient in high concurrency] deeply understand the basis of C language and C language under assembly
Reading mysql45 lecture - index continued
微信公众号服务器配置








