当前位置:网站首页>ThreadLocal内存泄漏是什么,怎么解决
ThreadLocal内存泄漏是什么,怎么解决
2022-07-02 00:13:00 【Add小兵】

实线代表强引用,虚线代表弱引用
每一个Thread维护一个ThreadLocalMap, key为使用弱引用的ThreadLocal实例,value为线程变量的副本。
强引用,使用最普遍的引用,一个对象具有强引用,不会被垃圾回收器回收。当内存空间不足,Java虚拟机宁愿抛出OutOfMemoryError错误,使程序异常终止,也不回收这种对象。
如果想取消强引用和某个对象之间的关联,可以显式地将引用赋值为null,这样可以使JVM在合适的时间就会回收该对象。
弱引用,JVM进行垃圾回收时,无论内存是否充足,都会回收被弱引用关联的对象。在java中,用java.lang.ref.WeakReference类来表示。
边栏推荐
- MySQL Replication中并行复制怎么实现
- 记录一下大文件上传偶然成功偶然失败问题
- Learn online case practice
- Asp .NetCore 微信订阅号自动回复之文本篇
- Use pair to do unordered_ Key value of map
- 使用VB.net将PNG图片转成icon类型图标文件
- Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
- Iota in golang
- Flow control statement of SQL data analysis [if, case... When detailed]
- [Qt] résoudre le problème que Qt msvc 2017 ne peut pas Compiler
猜你喜欢

回顾数据脱敏系统

基于全志H3的QT5.12.9移植教程

algolia 搜索需求,做的快自闭了...
![[QT] QT cannot find a solution to the compiler using msvc2017](/img/80/a4b17d6cc1ab6fe1366a3a3f43ec2e.png)
[QT] QT cannot find a solution to the compiler using msvc2017

heketi 记录

SQL数据分析之子查询的综合用法和案例题【耐心整理】

数据分析方法论与前人经验总结【笔记干货】

Kubernetes resource object introduction and common commands (III)

SQL数据分析之窗口排序函数rank、dense_rank、raw_number与lag、lead窗口偏移函数【用法整理】

Pytorch learning record
随机推荐
.env.xxx 文件,加了常量,却undefined
Chapter 6 data flow modeling
Selectively inhibiting learning bias for active sampling
B tree and b+tree of MySQL
Which securities company is the best to open a stock account? Is there a security guarantee
Example explanation: move graph explorer to jupyterlab
SQL Server 安裝指南
时间复杂度与空间复杂度
RPA教程01:EXCEL自动化从入门到实操
The essence of software architecture
启牛学院开户安全的吗?开户怎么开?
Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]
Ldr6035 smart Bluetooth audio can continuously charge and discharge mobile devices
PyTorch学习记录
Why does blocprovider feel similar to provider?
[QT] solve the problem that QT MSVC 2017 cannot compile
Windows10 install WSL (I) (wslregisterdistribution error)
SecurityUtils.getSubject().getPrincipal()为null的问题怎么解决
Dongge cashes in and the boss retires?
USB-IF协会与各种接口的由来