Re: What has managed code achieved?
On Fri, 24 Oct 2008 14:01:58 -0500, "Alex Clark" wrote:
I think that this is what Ben is saying, and I can confirm that it is
absolutely true. The above "Set objRef = Nothing" is like setting a
string to vbNullString before leaving a sub/function ... it frees
memory but that would happen automatically anyway.
Apart from API calls handled improperly, the only way to produce those
memory leaks that VB is allegedly well known for is to have unresolved
circular object references.
Hehe! :-)
Wolfgang
On Fri, 24 Oct 2008 14:01:58 -0500, "Alex Clark" wrote:
>Just to clarify, are you saying that in VB6 if you didn't de-reference an
>object before it went out of scope, it would automatically be cleaned up
>anyway? I'm not saying this in an accusatory manner, but everything I ever
>read in terms of good practice and even articles on MSDN seemed to imply
>otherwise - in fact I can even remember it being touted as a selling point
>to upgrade to VB.NET.
>
>Example (VB6):
>
>Private Sub Test()
>
Dim objRef As SomeClass
Set objRef = New SomeClass
' ...
' ...
Set objRef = Nothing ' <--- Dereferencing before it goes out of scope
>
>End Sub
>
>Are you saying that the last line, "Set objRef = Nothing", was therefore
>unneccesary in VB6?
>object before it went out of scope, it would automatically be cleaned up
>anyway? I'm not saying this in an accusatory manner, but everything I ever
>read in terms of good practice and even articles on MSDN seemed to imply
>otherwise - in fact I can even remember it being touted as a selling point
>to upgrade to VB.NET.
>
>Example (VB6):
>
>Private Sub Test()
>
Dim objRef As SomeClass
Set objRef = New SomeClass
' ...
' ...
Set objRef = Nothing ' <--- Dereferencing before it goes out of scope
>
>End Sub
>
>Are you saying that the last line, "Set objRef = Nothing", was therefore
>unneccesary in VB6?
absolutely true. The above "Set objRef = Nothing" is like setting a
string to vbNullString before leaving a sub/function ... it frees
memory but that would happen automatically anyway.
Apart from API calls handled improperly, the only way to produce those
memory leaks that VB is allegedly well known for is to have unresolved
circular object references.
>[...] then apparently VB6 was a bit smarter than I gave it credit for!
Wolfgang
Comment