LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Array Question

If the array is at the module level (not within a Sub or Function
procedure), then it would need to be cleaned up

guess you only left out how to clean it up. For a fixed - size array such
as you descibe as module level.

Public MyArray(1 to 60000, 1 to 256) as Variant

how would you clean that up?

Sub ABC()
if some condition then
' code to clean up array from
' Ronald goes he - don't use Erase please
else
for i = 1 to 60000
for j = 1 to 256
myarray(i,j) = rnd()*i*j
next
next
End if
end sub


--
Regards,
Tom Ogilvy


"Ronald Dodge" wrote:

I know prior versions of Office had VBA Project limits of about 64MB. For
the most part, when it comes to arrays, it can get to be very costly as I
would look at 3 things:

The type of data the arrays are declared. Variant Data Type takes 22 bytes
per element and string data types are multiplied by the number of characters
in each element. If the number of characters in the element is 0, assume
it's 1 instead for the size purpose.

Number of Dimensions

Number of elements for each dimension

What is the total size of the array?

Multiply by the number of elements of each dimension, then multiply that by
the number of bytes it takes for the data type that the array is declared
as, and that gives you the total size in bytes of the array.

Do you need to clear these arrays?

Well that's a depend question. In general, it would be good programming
practice to clean these up when the program no longer need to rely on these
arrays. However, to answer this question, we need to look at the scope that
the array variable is at.

If the array is at the module level (not within a Sub or Function
procedure), then it would need to be cleaned up or at least understand the
risks of not having this cleaned up as it remains open for as long as it's
not cleaned up.

If the array is a procedure level (within a Sub or Function procedure), then
it wouldn't necessarily need to be cleaned up, but I have found certain
cases where objects seems to get left out there in the RAM and no longer
attached to anything, which is what cases memory leakage, so to prevent this
sort of issue, one needs to clean things up. If the scope part works as
expected, it would clean itself up when the procedure is ended, but I have
found cases where this isn't working properly, thus one of the big types of
reasons why I don't use the MS Query tool as it is a major memory leakage
issue when using ADO coding via the MS Query tool.

--
Ronald R. Dodge, Jr.
Production Statistician/Programmer
Master MOUS 2000

"Sandy" wrote in message
...
I use several large array's in a sub routine. Do I need to clear these

arrays
in some form before leaving the routine?

Thank you






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array question AD108 Excel Programming 2 September 6th 06 05:11 PM
array question Gary Keramidas Excel Programming 4 October 18th 05 05:45 AM
array question Gary Keramidas[_4_] Excel Programming 4 October 4th 05 03:40 AM
Array Question andym Excel Programming 3 September 2nd 04 02:34 PM
Array question mickiedevries[_9_] Excel Programming 3 August 24th 04 06:58 PM


All times are GMT +1. The time now is 07:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"