473,473 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Freeing Dynamic Arrays

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, 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?

Thanks,
Dave
Jun 27 '08 #1
2 2095
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.
Jun 27 '08 #2
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!
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Scott Lyons | last post by:
Hey all, Can someone help me figure out how to pass a dynamic array into a function? Its been giving me some trouble, and my textbook of course doesnt cover the issue. Its probably something...
11
by: Rodrigo Dominguez | last post by:
there are sometimes that I use third party libraries, I use some functions that returns char * or structs, etc. sometimes the memory that is returned by those libraries, when I try to free this...
4
by: learnfpga | last post by:
Here is a little code I wrote to add the numbers input by the user.....I was wondering if its possible to have the same functionality without using dynamic arrays.....just curious..... ...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
4
by: hobbes992 | last post by:
Howdy folks, I've been working on a c project, compiling using gcc, and I've reached a problem. The assignment requires creation of a two-level directory file system. No files have to be added or...
5
Delerna
by: Delerna | last post by:
Been playing around with DirectX 10 in C++ and I have been using arrays to store info for vertex buffers. To simplify my question I will drop DX10 from the equation. I am an experienced programmer...
9
by: david | last post by:
I will past only two segments from the code it should be enough to see what I did wrong, I think I know there I made a mistake, but how to fix it I can not tell. This why I need help from you all....
11
by: vivek | last post by:
Hello, I have a pointer to a main structure which again consists of structures, enums, char, int, float and again complex structures. When i free all the contents of the main structure, it...
1
by: headware | last post by:
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.