Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道如果一个对象没有引用,并且 GC 清除了它,该对象的 WeakReference.Target 属性将返回 null,
但是假设对象没有强引用,而 GC 还没有清除它,是否有办法通过它的 WeakReference 检查它是否有任何强引用?
否 - 这取决于对象是否具有 GC 根。GC 在运行之前不会确定这一点。
查看这篇 MSDN 杂志文章(第 1 部分和第 2 部分),了解有关 .Net 中 GC 的更多信息。
** 更新 ** 感谢@Adriano 提供第 2 部分链接。