由于 GC 检测对象图的孤立孤岛以找到从内存中删除的候选对象,并且 WeakMap 不会用弱引用打破孤岛边界,那么这个引用也不用弱引用打破孤岛边界是WeakMap -> KeyObject
有意义的,而引用显然是强的。WeakMap -> Value -> KeyObject
WeakMap -> Value
Value -> KeyObject
例子:
let o = {test:1};
let map = new WeakMap();
map.set(o, {strongRef: o});
o = null; // clear last reference on {test:1}
// will {test:1} be GCed after this ?