当前位置:网站首页>ThreadLocal内存泄漏是什么,怎么解决
ThreadLocal内存泄漏是什么,怎么解决
2022-07-02 00:13:00 【Add小兵】
实线代表强引用,虚线代表弱引用
每一个Thread维护一个ThreadLocalMap, key为使用弱引用的ThreadLocal实例,value为线程变量的副本。
强引用,使用最普遍的引用,一个对象具有强引用,不会被垃圾回收器回收。当内存空间不足,Java虚拟机宁愿抛出OutOfMemoryError错误,使程序异常终止,也不回收这种对象。
如果想取消强引用和某个对象之间的关联,可以显式地将引用赋值为null,这样可以使JVM在合适的时间就会回收该对象。
弱引用,JVM进行垃圾回收时,无论内存是否充足,都会回收被弱引用关联的对象。在java中,用java.lang.ref.WeakReference类来表示。
边栏推荐
- From 20s to 500ms, I used these three methods
- 下载在线视频 m3u8使用教程
- Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]
- 起床困难综合症(按位贪心)
- Correlation - intra group correlation coefficient
- SQL Server 安裝指南
- Windows installation WSL (II)
- 记录一下大文件上传偶然成功偶然失败问题
- Asp . Text of automatic reply to NETCORE wechat subscription number
- Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
猜你喜欢
起床困难综合症(按位贪心)
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
Using uni simple router, dynamically pass parameters typeerror: cannot convert undefined or null to object
[es practice] safe operation mode on ES
实例讲解将Graph Explorer搬上JupyterLab
SQL Server 安装指南
如何提升数据质量
SQL数据分析之子查询的综合用法和案例题【耐心整理】
Algolia's search needs are almost closed
[cmake] cmake configuration in QT Creator
随机推荐
Linux centos7 installation Oracle11g super perfect novice tutorial
SQL Server 安裝指南
From 20s to 500ms, I used these three methods
Guide d'installation du serveur SQL
Digital transformation has a long way to go, so how to take the key first step
Ldr6035 smart Bluetooth audio can continuously charge and discharge mobile devices
What is the purpose of ERP project implementation plan?
回顾数据脱敏系统
Jielizhi Bluetooth headset quality control and production skills [chapter]
起床困难综合症(按位贪心)
关联性——组内相关系数
How excel opens CSV files with more than one million lines
PyTorch学习记录
An intern's journey to cnosdb
SQL数据分析之窗口排序函数rank、dense_rank、raw_number与lag、lead窗口偏移函数【用法整理】
Iota in golang
记录一下大文件上传偶然成功偶然失败问题
实例讲解将Graph Explorer搬上JupyterLab
Leetcode 96 différents arbres de recherche binaires
[QT] qtcreator uninstall and installation (abnormal state)