Freeing Dynamic Arrays

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
 
P

Peter Bromberg [C# MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,073
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top