当前位置:网站首页>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
边栏推荐
- VMware Tools installation error: unable to automatically install vsock driver
- Recursive method to realize the insertion operation in binary search tree
- Intensive learning weekly, issue 52: depth cuprl, distspectrl & double deep q-network
- Synchronized and reentrantlock
- Vulhub vulnerability recurrence 74_ Wordpress
- Use of crawler manual 02 requests
- How to get the PHP version- How to get the PHP Version?
- 可恢复保险丝特性测试
- Leetcode1961. 检查字符串是否为数组前缀
- Overview of Zhuhai purification laboratory construction details
猜你喜欢
1791. Find the central node of the star diagram / 1790 Can two strings be equal by performing string exchange only once
Vulhub vulnerability recurrence 75_ XStream
General operation method of spot Silver
Finding the nearest common ancestor of binary search tree by recursion
基于DVWA的文件上传漏洞测试
Convert binary search tree into cumulative tree (reverse middle order traversal)
The third season of ape table school is about to launch, opening a new vision for developers under the wave of going to sea
After 95, the CV engineer posted the payroll and made up this. It's really fragrant
Cf:d. insert a progression [about the insert in the array + the nature of absolute value + greedy top-down]
Five challenges of ads-npu chip architecture design
随机推荐
WordPress collection plug-in automatically collects fake original free plug-ins
[day 30] given an integer n, find the sum of its factors
Who knows how to modify the data type accuracy of the columns in the database table of Damon
esxi的安装和使用
Leetcode 剑指 Offer 59 - II. 队列的最大值
[Arduino syntax - structure]
伦敦银走势中的假突破
Getting started with devkit
SAP Spartacus home 页面读取 product 数据的请求的 population 逻辑
Convert binary search tree into cumulative tree (reverse middle order traversal)
MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
I'm interested in watching Tiktok live beyond concert
Four commonly used techniques for anti aliasing
GNSS terminology
Finding the nearest common ancestor of binary tree by recursion
Promise
Lone brave man
Live video source code, realize local storage of search history
ADS-NPU芯片架构设计的五大挑战
Illustrated network: the principle behind TCP three-time handshake, why can't two-time handshake?