Re: Freeing Dynamic Arrays by headware
headware
Wed May 14 11:11:56 CDT 2008
On May 12, 2:52 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
> headware wrote:
> > Do dynamic arrays declared using ReDim have to be freed? I assume that
> > if it's an array of dynamically created objects (e.g.
> > Scripting.Dictionary), each one of those objects will have to be set
> > to Nothing in a for loop,
>
> Depending on the type of object, even that is not necessary since they
> will be released when they go out of scope. Of course, it doesn't hurt
> to do it. With ADO connections, it's probably a good idea to be explicit
> about closing and destroying them. With Dictionary objects, it's
> probably overkill.
>
> > but what about the array itself? Or what if
> > the array is dynamic but it just consists of integers or strings, not
> > dynamically allocated objects? Does it have to be set to Nothing?
>
> Arrays are not objects so they cannot be set to nothing. Many years ago
> i read somewhere that it was a good idea to use Erase to clear arrays
> when done with them, but I have not seen that advice anywhere since.
> Again, it can't hurt.
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
Thanks!