Freeing Dynamic Arrays

Discussion in 'ASP .Net' started by headware, May 14, 2008.

  1. headware

    headware Guest

    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
     
    headware, May 14, 2008
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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], May 14, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. countofquad
    Replies:
    4
    Views:
    389
    countofquad
    Mar 5, 2005
  2. Freeing Reallocated arrays

    , Aug 19, 2008, in forum: C Programming
    Replies:
    1
    Views:
    323
    Ian Collins
    Aug 19, 2008
  3. Philipp
    Replies:
    21
    Views:
    1,157
    Philipp
    Jan 20, 2009
  4. headware

    Freeing Dynamic Arrays

    headware, May 12, 2008, in forum: ASP General
    Replies:
    2
    Views:
    109
    headware
    May 14, 2008
  5. headware

    Freeing Dynamic Arrays

    headware, May 14, 2008, in forum: ASP General
    Replies:
    1
    Views:
    117
    Bob Barrows [MVP]
    May 14, 2008
Loading...

Share This Page