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.Dicti onary), 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 2 2122
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.Dicti onary), 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.
On May 12, 2:52 pm, "Bob Barrows [MVP]" <reb01...@NOyah oo.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.Dicti onary), 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! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 simple, but its just not popping into my mind
at the moment.
My little snippet of code is below. Basically, the studentID array is
dynamic so it will fit any length of a Student's Name. What I'm trying to
do is place this chunk of code into a...
|
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 memory whith the function free,
it brokes my application, and sometimes it's ok, why? how do I realize when
I have to free the memory that is allocated by third party libraries and
why sometimes I don't have to free this memory?
Thank you
|
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.....
//trying to get input from the user to add all the numbers that user
inputs
//tried to do it without dynamic memory usage but probably cannot
achieve it
//here is using "new" and "delete" operator....
|
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, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply.
Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money.
Note The above informaton is...
|
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 deleted, however it must be initialized by a function during run-time to contain so many users which each contain so many directories of which each contain so many files. I've completed the program and have it running flawlessly without implementing...
| |
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 but have only dabbled in C++.
To The Point.
If i declare a variable ready for use as a dynamic array
int* ArrayName;
and initialize it so it has a size of 1
ArrayName=new int ;
|
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.
Main code:
----------------
/* duomenu rasymas i faila */
dst = fopen(argv, "w");
if (dst != NULL) {
wordDBSize = sizeStack(wordDB);
|
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 takes me a lot
of time (since i have to loop determining the data type and freeing
it). Is there any idea to free all the contents of the structure in
shortest possible time.
|
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 " & i
Next
Do have I have set Test = Nothing to prevent a memory leak?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |