Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Freeing Dynamic Arrays (http://www.velocityreviews.com/forums/t614809-freeing-dynamic-arrays.html)

headware 05-14-2008 03:31 PM

Freeing Dynamic Arrays
 
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

Peter Bromberg [C# MVP] 05-14-2008 08:18 PM

Re: Freeing Dynamic Arrays
 
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

"headware" <david.k.land@gmail.com> wrote in message
news:a7e2fa67-a37b-4a98-bbda-ecf69bdcea04@56g2000hsm.googlegroups.com...
> 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




All times are GMT. The time now is 08:24 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57