当前位置:网站首页>What is ThreadLocal memory leak and how to solve it
What is ThreadLocal memory leak and how to solve it
2022-07-02 00:14:00 【Add soldier】

Solid lines represent strong quotes , Dashed lines represent weak references
every last Thread Maintain a ThreadLocalMap, key For the use of Weak reference Of ThreadLocal example ,value Is a copy of the thread variable .
Strong citation , Use the most common quotation , An object has a strong reference , It won't be recycled by the garbage collector . When memory runs out of space ,Java The virtual machine would rather throw OutOfMemoryError error , Causes the program to terminate abnormally , And don't recycle the object .
If you want to disassociate a strong reference from an object , You can explicitly assign references to null, This will enable JVM The object will be recycled at the right time .
Weak reference ,JVM When recycling , Whether the memory is sufficient or not , All objects associated with weak references will be recycled . stay java in , use java.lang.ref.WeakReference Class .
边栏推荐
- Practical calculation of the whole process of operational amplifier hysteresis comparator
- .env.xxx 文件,加了常量,却undefined
- SQL Server 安装指南
- Correlation - intra group correlation coefficient
- GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
- Windows 7 install MySQL error: 1067
- 在证券账户上买基金安全吗?哪里可以买基金
- 启牛商学院给的证券账户安不安全?哪里可以开户
- 多表操作-一对一,一对多与多对多
- Halcon knowledge: an attempt of 3D reconstruction
猜你喜欢

使用多线程Callable查询oracle数据库

Leetcode 96 différents arbres de recherche binaires

【QT】對於Qt MSVC 2017無法編譯的問題解决

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

Digital transformation has a long way to go, so how to take the key first step

Shell process control

Asp .NetCore 微信订阅号自动回复之文本篇

Relatively easy to understand PID understanding

RPA教程01:EXCEL自动化从入门到实操

LDR6035智能蓝牙音响可充可放(5.9.12.15.20V)快充快放设备充电
随机推荐
启牛学院开户安全的吗?开户怎么开?
Guide d'installation du serveur SQL
Download the online video m3u8 tutorial
UDS bootloader of s32kxxx bootloader
Resumption of attack and defense drill
多表操作-一对一,一对多与多对多
ERP项目施行计划的目的是什么?
Jielizhi, production line assembly link [chapter]
Digital transformation has a long way to go, so how to take the key first step
[Qt] résoudre le problème que Qt msvc 2017 ne peut pas Compiler
一个实习生的CnosDB之旅
Use vb Net to convert PNG pictures into icon type icon files
Windows10 install WSL (I) (wslregisterdistribution error)
Timer和ScheduledThreadPoolExecutor的区别
Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS
LDR6035智能蓝牙音响可充可放(5.9.12.15.20V)快充快放设备充电
From 20s to 500ms, I used these three methods
USB-IF协会与各种接口的由来
cookie、session、tooken
Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]