Reputation: 13
I just want to check if I write following codes in vb6:
dim a as new b
dim a as new b
will it cause the memory leak or not?
Upvotes: 1
Views: 115
Reputation: 3189
That code won't even compile because you are defining A twice.
However, in this example:
Dim A As B
Set A = New B
Set A = New B
After the third line, the first instance of B stored in A on the second line will be destroyed.
Upvotes: 3
Reputation: 4007
No, this will not cause a memory leak.
You can also put this code in a loop of 10000 iterations and look at your memory in Task Manager.
Upvotes: 2