Say I have a function
说我有一个功能
Private Sub DoThing()
Dim o As ComplexObject ' with possible backreference
Set o = ComplexThing()
Call DoStuff(o)
End Sub
My instinct tells me that o
will be set to Nothing
(and thus garbage-collected) once the function exits, but I can't find any documentation to confirm or refute this.
我的直觉告诉我,一旦函数退出,o将被设置为Nothing(并因此被垃圾收集),但我找不到任何文档来确认或反驳这一点。
1 个解决方案
#1
2
Yes, as long as DoStuff() doesn't do any operation that would increase the reference counter of o, it's reference count will be come 0 and it's resources will be freed at that time.
是的,只要DoStuff()不执行任何会增加o的引用计数器的操作,它的引用计数将为0并且它的资源将在那时被释放。
#1
2
Yes, as long as DoStuff() doesn't do any operation that would increase the reference counter of o, it's reference count will be come 0 and it's resources will be freed at that time.
是的,只要DoStuff()不执行任何会增加o的引用计数器的操作,它的引用计数将为0并且它的资源将在那时被释放。