当前位置:网站首页>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 .
边栏推荐
- 4. Object mapping Mapstercover
- PWN attack and defense world cgpwn2
- 电商RPA机器人,助力品牌电商抢立流量高点
- cookie、session、tooken
- 牛客-练习赛101-推理小丑
- Kubernetes resource object introduction and common commands (III)
- RPA教程01:EXCEL自动化从入门到实操
- [QT] solve the problem that QT MSVC 2017 cannot compile
- Multi table operation - one to one, one to many and many to many
- 数据分析方法论与前人经验总结【笔记干货】
猜你喜欢
Learn online case practice
How to solve the image pop-up problem when pycharm calls Matplotlib to draw
[QT] solve the problem that QT MSVC 2017 cannot compile
多表操作-一对一,一对多与多对多
Linux CentOS7安装Oracle11g的超完美新手教程
【CMake】Qt creator 里面的 cmake 配置
EMC circuit protection device for surge and impulse current protection
[Qt] résoudre le problème que Qt msvc 2017 ne peut pas Compiler
LDR6035智能蓝牙音响可对手机设备持续充放电方案
Relatively easy to understand PID understanding
随机推荐
MySQL: the difference between insert ignore, insert and replace
Correlation - intra group correlation coefficient
13 MySQL constraint
RPA教程01:EXCEL自动化从入门到实操
Selectively inhibiting learning bias for active sampling
mysql之B tree 以及 B+tree
. env. XXX file, with constant, but undefined
【QT】对于Qt MSVC 2017无法编译的问题解决
Iota in golang
Ldr6035 smart Bluetooth audio can continuously charge and discharge mobile devices
Guide d'installation du serveur SQL
Practical calculation of the whole process of operational amplifier hysteresis comparator
SQL数据分析之窗口排序函数rank、dense_rank、raw_number与lag、lead窗口偏移函数【用法整理】
Flow control statement of SQL data analysis [if, case... When detailed]
Asp .NetCore 微信订阅号自动回复之文本篇
正则表达式收集
Key points of security agreement
北京炒股开户选择手机办理安全吗?
[QT] test whether QT can connect to the database
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?