当前位置:网站首页>《JVM》对象内存分配的TLAB机制与G1中的TLAB流程
《JVM》对象内存分配的TLAB机制与G1中的TLAB流程
2022-06-25 08:19:00 【快乐的星球】
文章目录
一:重温对象的生命周期
1.1 对象生命周期流程图

1.2 重点强调
对象的finalize()方法只会被调用一次,也就是说对象只能有一次复活机会,但对象的复活会破坏对象的生命周期,干扰了JVM对对象的收集,因此在finalize()方法中一般写对象收集前的资源释放工作。
二: TLAB(内存分配缓冲区)
由上图中的对象的生命周期中,我们了解到了对象在使用前要先进行对象的内存分配与初始化操作,接下来我们讲述对象内存分配的两种策略
2.1 为什么要有TLAB
我们知道对象内存分配时最初考虑在新生代的Eden区为对象分配内存,但堆区是线程共享的区域,在多线程环境下多个线程同时操控同一块内存的现象是普遍的,为了保证对象分配时数据的安全性,我们需要用全局锁来解决多线程同时访问同一块内存的问题,但全局锁会降低效率与程序的吞吐量,为了解决该问题TLAB应运而生。
2.2 TLAB
TLAB对Eden区的内存进行了划分,划分出一小块区域,这块区域称为对象内存分配缓冲区,它为每一个线程都分配了一块空间。
优点:
- 使用TLAB可以避免一系列的线程安全问题。
- 提高了程序运行的效率与吞吐量。
这种使用TLAB进行内存分配的策略称为快速分配策略。
三:G1源码中的TLAB策略
3.1 简介
分配空间时,为了提高JVM的运行效率,应当尽量减少临界区范围,避免全局锁。G1的通常的应用场景中,会存在大量的访问器同时执行,为减少锁冲突,JVM引入了TLAB(线程本地分配缓冲区Thread Local Allocation Buffer)机制。
3.2 流程图
根据源码梳理可得以下流程图:
如果对你有帮助的话,不要忘了点赞收藏啦!
边栏推荐
- Fault: 0x800ccc1a error when outlook sends and receives mail
- [opencv] - input and output XML and yaml files
- 声纹技术(三):声纹识别技术
- Webgl Google prompt memory out of bounds (runtimeerror:memory access out of bounds, Firefox prompt index out of bounds)
- atguigu----01-脚手架
- 【期末复习笔记】数字逻辑
- jmeter中csv参数化
- socket编程——poll模型
- 3大问题!Redis缓存异常及处理方案总结
- 城鏈科技平臺,正在實現真正意義上的價值互聯網重構!
猜你喜欢

matplotlib matplotlib中axvline()和axhline()函数

Unity--configurable joint -- a simple tutorial to get you started with configurable joints

cazy長安戰役八卦迷宮

五、项目实战---识别人和马

Explanation of assertions in JMeter

C#程序终止问题CLR20R3解决方法

行业春寒回暖,持续承压的酒店企业于何处破局?

Wechat applet_ 7. Project practice, local life

matplotlib matplotlib中plt.grid()

Le labyrinthe des huit diagrammes de la bataille de cazy Chang'an
随机推荐
C#启动程序传递参数丢失双引号,如何解决?
3、 Automatically terminate training
声纹技术(三):声纹识别技术
Unity--configurable joint -- a simple tutorial to get you started with configurable joints
三、自动终止训练
C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large
Swiperefreshlayout+recyclerview failed to pull down troubleshooting
socket编程——epoll模型
Where are the hotel enterprises that have been under pressure since the industry has warmed up in spring?
QSS buttons of different styles
matplotlib matplotlib中决策边界绘制函数plot_decision_boundary和plt.contourf函数详解
Unity发布webGL的时候JsonConvert.SerializeObject()转换失败
In Section 5 of bramble pie project practice, Nokia 5110 LCD is used to display Hello World
《乔布斯传》英文原著重点词汇笔记(二)【 chapter one】
mysql之Unknown table ‘COLUMN_STATISTICS‘ in information_schema (1109)
Notes on key vocabulary of the original English work biography of jobs (I) [introduction]
Stimulsoft ultimate presents reports and dashboards
2、 Training fashion_ MNIST dataset
关掉一个线程
sklearn 高维数据集制作make_circles 和 make_moons