当前位置:网站首页>JVM four reference types
JVM four reference types
2022-07-28 18:48:00 【A dream without trace BZY】
One 、 Strong citation :
natural new When an object is referred to, it is a strong reference . You can manipulate objects directly by reference .gc Objects pointed to by strong references will not be recycled , Unless the reference is equal to null
Two 、 Soft citation
new Out SoftReference Nest other objects in its construction method

1、m Point to sr Strong citation ,sr Object points to byte array soft reference . Every time gc It will not actively clean up soft references , Only when there are other strong references , And if the space in the heap area is insufficient, it will be cleared . You can quote .get Method to get nested objects
2、 effect : Used to cache , Set some frequently used as soft references ( Give Way SoftReference Nesting things to be used in ), So it won't be gc Recycle , Can be used often . And when there is not enough memory , It can be killed by other strong references at any time
3、 ... and 、 Weak reference
new Out WeakReference Nest other objects in its construction method
1、 Memory diagram as above . As long as garbage collection starts, it will be recycled . You can quote .get Method to get nested objects
2、 effect : stay ThreadLocal To prevent memory leakage ( See the multi threading column ThreadLocal)
Four 、 Virtual reference
new Out PhantomReference Nest other objects in its construction method

You have to add a queue , Because every time I was returned
边栏推荐
- LeetCode_63_不同路径Ⅱ
- 1.1、稀疏数组
- APP为什么用JSON协议与服务端交互:序列化相关知识
- Summer Challenge [FFH] JS custom component: DIY a keyboard that can be used at any time! (I)
- 实验楼----PHP大法
- 高德地图实现自定义小蓝点 自定义点标记 绘制多边形/圆形区域 根据地图的移动显示或者隐藏自定义点标记的相关实现
- Digital torrent: resource reorganization and strategic conflict in enterprise transformation
- 面试官:ThreadLocal使用场景有哪些?内存泄露问题如何避免?
- 数字化转型中的DevOps——弹性合作
- jvm调优
猜你喜欢

使用自开发的代理服务器解决 SAP UI5 FileUploader 上传文件时遇到的跨域访问错误试读版

Wired: who owns the art of the future? Openai allows dall-e users to commercialize their works. At present

不理解模块化、组件化、插件化的区别怎么行?

当Golang遇到高并发秒杀

Go concurrency one

It is said that software testing is the worst in the IT industry. Is that so?

GC垃圾回收器详解

LeetCode_96_不同的二叉搜索树

What is one hot code? Why use it and when?

@The difference between Autowired and @resource
随机推荐
1.1、稀疏数组
LeetCode_ 63_ Different paths II
What if you don't understand the difference between modularity, componentization and plug-in?
Ue5 gas learning notes 1.4 attribute set
redis优势以及数据结构相关知识
Summer Challenge [FFH] JS custom component: DIY a keyboard that can be used at any time! (I)
haproxy实现代理配置
Introduction and advanced level of MySQL (6)
redis持久化之RDB和AOF的区别
MYSQL入门与进阶(五)
Golang 并发之锁
数字化转型中的DevOps——弹性合作
SQL Server stuff and for XML path
LVS manual
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
2022年中国企业服务产业市场行情
Go并发详解之一
GO exe生成图标版本信息
What are the conditions for zero foundation learning software testing?
面试官:ThreadLocal使用场景有哪些?内存泄露问题如何避免?