当前位置:网站首页>Memory allocation and recycling strategy
Memory allocation and recycling strategy
2022-07-24 17:19:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Memory allocation and recycling strategy
Priority is given to Eden Distribute
Most of the time , The object is the new generation Eden Regional distribution . When Eden When there is not enough space for allocation , The virtual machine will launch once Minor GC.
- Minor GC: Refers to the garbage collection in the new generation , because Java Most of the objects have the characteristics of living and dying , therefore Minor GC Very often , Generally, the recycling speed is also relatively fast .
- Full GC: Refers to what happened in the old days GC, There is Full GC, Often accompanied at least once Minor GC,Full GC It's usually faster than Minor GC slow 10 More than times .
Large objects go directly into the old generation
Large objects are those that require a large amount of continuous memory space Java object , Such as long strings or data .
A large object can be stored in Eden The probability of a zone is relatively small , The probability of distribution guarantee is relatively high , And distributing guarantees involves a lot of duplication , It's inefficient .
The virtual machine provides one -XX:PretenureSizeThreshold Parameters , Make objects larger than this setting directly allocated in the elderly generation , The purpose of this is to avoid Eden District and two Survivor There are a lot of memory copies between regions .
Long term survivors will enter the old age
JVM An object age counter is defined for each object . When the Cenozoic happens once Minor GC after , The age of the survivors +1, When the age is over a certain value , All objects exceeding this value will be transferred to the old age .
Use -XXMaxTenuringThreshold Set the maximum age of the new generation , As long as the new generation object exceeds this parameter, it will be transferred to the old age .
Dynamic object age determination
If the current new generation Survivor in , The sum of all object sizes of the same age is greater than Survivor Half of the space , Age >= People of that age can directly enter the old generation , Don't wait for MaxTenuringThreshold The age required in .
Space allocation guarantee
JDK 6 Update 24 The previous rule was this :
In the event of a Minor GC Before , Virtual opportunity first check Is the maximum available continuous space in the old age greater than the total space of all objects in the new generation , If this condition holds ,Minor GC To make sure it's safe ; If not , Then virtual opportunity view HandlePromotionFailure Value is set to allow guarantee failure , If it is , Then it continues to check whether the maximum available contiguous space in the old age is greater than the average size of the objects that have been promoted to the old age , If it is greater than , There will be an attempt to Minor GC, Even though this time Minor GC There are risks ; If it is less than , perhaps HandlePromotionFailure Set not to take risks , At this time, we have to do it again Full GC.
JDK 6 Update 24 And then the rule became :
As long as the continuous space of the old age is larger than the total size of the new generation of objects or the average size of previous promotions , It will Minor GC, Otherwise, it will be Full GC.
Expand the free space of the older generation by removing the discarded data of the older generation , In order to guarantee the new generation .
The process is to distribute guarantees .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/107451.html Link to the original text :https://javaforall.cn
边栏推荐
- Demonstration experiment of scrollbar for adjusting image brightness
- Iftnews | Christie's launched its venture capital department, aiming at Web3 and metauniverse industries
- Navicate connects Alibaba cloud (explanation of two methods and principles)
- The orders in the same city are delivered in the same city, and the order explosion is still handy!
- portfwd 端口转发
- Mysql增删改查、检索与约束(详细教学)
- Rare earth Developer Conference | Apache pulsar committee Liu Dezhi shares the way of cloud native technology transformation
- Is it safe for Mr. qiniu to open a securities account? Can I drive it?
- What is fuzzy theory, foundation and process
- Bring 120W goods in 15 seconds. You can also shoot such a popular video
猜你喜欢

Axi protocol (1): introduction to AMBA bus, introduction to Axi concept and background, characteristics and functions of Axi protocol

SS-Paper【1】:Fully Convolutional Networks for Semantic Segmentation

Opencv has its own color operation
![为什么被调函数内部不能用 sizeof(arr) / size(arr[0]) 计算数组长度?](/img/e6/1d2213f3eb9bd0ff537a66d2b01f98.png)
为什么被调函数内部不能用 sizeof(arr) / size(arr[0]) 计算数组长度?

Axi protocol (2): five channels and two transactions of Axi architecture

CDN(Content Delivery Network)内容分发网络从入门到与实战

Keyboard input operation

JSP custom tag library --foreach

socat 端口转发

Using unity to do simulation, I don't allow this chart plug-in, you don't know
随机推荐
Want to make sandbox games? Then you must not miss this plug-in (unity3d)
1309. Decode letter to integer mapping
QT QML virtual keyboard
Notebook computer purchase guide (specific brand and model are not recommended)
Atcoder Beginner 202 E - Count Descendants(离线查询 重链剖分树上启发式合并)
Baidu PaddlePaddle easydl x wesken: see how to install the "eye of AI" in bearing quality inspection
还在用Xshell?你out了,推荐一个更现代的终端连接工具!
荣耀CEO赵明:单一厂商很难实现全场景产品覆盖
OS Experiment 5 process switching based on kernel stack switching
Pat class A - A + B format
AXI协议(1):AMBA总线介绍,AXI概念与背景介绍,AXI协议特点与功能
Demonstration experiment of scrollbar for adjusting image brightness
Canvas from getting started to persuading friends to give up (graphic version)
Coldplay weekly issue 10
AutoCAD - join merge command
JS to implement a promise of promises/a+ specification
Concept of IP, classification of IP, IP multiplexing technology
Apachecon Asia 2022 opens registration: pulsar technology issues make a big debut
HCNP Routing&Switching之DHCP中继
Why can't sizeof (ARR) / size (arr[0]) be used to calculate the array length inside the called function?