当前位置:网站首页>What is weak reference? What are the weak reference data types in ES6? What are weak references in JS?
What is weak reference? What are the weak reference data types in ES6? What are weak references in JS?
2022-07-06 01:15:00 【imkaifan】
Weak reference :
WeakSet The objects in are all weak references , Garbage collection mechanism does not consider WeakSet Reference to the object , in other words , If no other object references that object , Then the garbage collection mechanism will automatically reclaim the memory occupied by the object , Regardless of whether the object still exists in WeakSet In .
This is because the garbage collection mechanism depends on the reachability of objects (reachability) To determine recycling , If the object can still be accessed , The garbage collection mechanism will not free this memory . After you finish using this value , Sometimes I forget to dereference , Causes memory not to be released , This can lead to memory leaks .WeakSet The quotation in it , Not included in the garbage collection mechanism , So there is no such problem . therefore ,WeakSet Suitable for temporary storage of a group of objects , And storing information bound to objects . As long as these objects disappear outside , It's in WeakSet The references in it will disappear automatically .
Because of the above characteristics ,WeakSet Members of are not suitable for reference , Because it will disappear at any time . in addition , because WeakSet How many members are there inside , Depends on whether the garbage collection mechanism is running , It is likely that the number of members before and after running is different , And when the garbage collection mechanism will run is unpredictable , therefore ES6 Regulations WeakSet Non traversal . And of course not size attribute , Because the amount of data is also uncertain .
These features also apply to WeakMap structure
边栏推荐
- 黄金价格走势k线图如何看?
- 记一个 @nestjs/typeorm^8.1.4 版本不能获取.env选项问题
- Opinions on softmax function
- BiShe - College Student Association Management System Based on SSM
- [day 30] given an integer n, find the sum of its factors
- Building core knowledge points
- A preliminary study of geojson
- Condition and AQS principle
- Study diary: February 13, 2022
- 新手入门深度学习 | 3-6:优化器optimizers
猜你喜欢
Introduction to robotics I. spatial transformation (1) posture, transformation
JVM_ 15_ Concepts related to garbage collection
Vulhub vulnerability recurrence 74_ Wordpress
3D model format summary
Mobilenet series (5): use pytorch to build mobilenetv3 and learn and train based on migration
Four commonly used techniques for anti aliasing
ubantu 查看cudnn和cuda的版本
Building core knowledge points
How to extract MP3 audio from MP4 video files?
Kotlin basics 1
随机推荐
Four commonly used techniques for anti aliasing
After 95, the CV engineer posted the payroll and made up this. It's really fragrant
Test de vulnérabilité de téléchargement de fichiers basé sur dvwa
Installation and use of esxi
基于DVWA的文件上传漏洞测试
FFT learning notes (I think it is detailed)
程序员成长第九篇:真实项目中的注意事项
激动人心,2022开放原子全球开源峰会报名火热开启
Some features of ECMAScript
Exciting, 2022 open atom global open source summit registration is hot
记一个 @nestjs/typeorm^8.1.4 版本不能获取.env选项问题
DOM introduction
关于#数据库#的问题:(5)查询库存表中每本书的条码、位置和借阅的读者编号
Synchronized and reentrantlock
Cve-2017-11882 reappearance
Introduction to robotics I. spatial transformation (1) posture, transformation
IP storage and query in MySQL
Cf:c. the third problem
Live broadcast system code, custom soft keyboard style: three kinds of switching: letters, numbers and punctuation
网易智企逆势进场,游戏工业化有了新可能