Freeing Dynamic Arrays

  • Thread starter Thread starter headware
  • Start date Start date
H

headware

Do you have to manually release memory allocated by creating a dynamic
array using ReDim? In other words, if I have the following code:

ReDim Test(1000)
For i = 0 To 1000
Test(i) = "test value " & i
Next

Do have I have set Test = Nothing to prevent a memory leak?

Thanks,
Dave
 
Firstly, arrays as you describe them are not "dynamic" - the VB.NET "Redim"
keyword simply creates a new array and copies the contents to it.
When an array goes out of scope, it is marked for garbage collection, so you
do not need to do anything.
Peter
 
Back
Top