Sean Allred
Sean Allred

Reputation: 3658

Are local objects garbage-collected once they fall out of scope?

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.

Upvotes: 0

Views: 43

Answers (1)

Eric Walker
Eric Walker

Reputation: 1052

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.

Upvotes: 2

Related Questions