Re: Redim
From: alpine (alpine_don'tsendspam_at_mvps.org)
Date: 02/01/05
- Next message: Rick Rothstein: "Re: Short Circuit Logical Execution?"
- Previous message: Barbara: "Re: Run hidden Form"
- In reply to: Carl: "Re: Redim"
- Next in thread: Gerald Hernandez: "Re: Redim"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 01 Feb 2005 11:15:19 -0700
On Tue, 1 Feb 2005 10:45:51 -0700, "Carl" <c@invalid.com> wrote:
>
>"alpine" <alpine_don'tsendspam@mvps.org> wrote in message
>news:lvevv0d3ljc29mo7ph7m44gtjl6t0096q0@4ax.com...
>> On Tue, 1 Feb 2005 09:57:41 -0700, "Carl" <c@invalid.com> wrote:
>>
>>>I am an amateur hobby programmer using VB6 Learner's Edition.
>>>I have a program that redimensions a one-dimension dynamic array according
>>>to the max number of items I may have in a list.
>>>
>>>I have successfully redimensioned the array at increasing values up to
>>>11,881,378.
>>>The next step is 308,915,778 but, when I redim to that value, I get an Out
>>>Of Memory error msg.
>>>
>>>I am using XP SP2 with 512 MB of memory.
>>>Maybe I am simply exceeding the upper limit of an array.
>>>
>>>Enlightenment appreciated.
>>>Carl
>>
>>
>> The maximum upper bound of an array is a Long value which would
>> translate to 2,147,483,647 so, you haven't exceeded that.
>> Furthermore, I believe you could set the lower bound to -2,147,483,648
>> which would double the available indices.
>>
>> What data type does this array consist of? I suspect it is your data
>> that is consuming the memory.
>>
>> HTH,
>> Bryan
>
>Bryan,
>Thanks. The array is dimensioned as a string. Dim TempArray() As String
>The Out Of Memory error occurs instantly, when the redim statement runs.
>I don't know how many bytes per element the OS is using, but even 2 will
>exceed my 512 MB or chip memory.
>As noted in my response to Jan, I thought the OS would use the hard drive as
>aux memory, but maybe not.
>Carl
I would guess that VB is attempting to allocate enough memory to copy
the entire contents of the array to a new cohesive memory block and
this is where the failure occurs. ReDimensioning arrays to a larger
size is expensive for this very reason. A best practice is to
dimension the array to the maximum size you will use the first time
you ReDim it and then remove any extra elements once you have all of
the data you want in the array.
HTH,
Bryan
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
alpine_don'tsendspam@mvps.org Hunter S. Thompson -
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
- Next message: Rick Rothstein: "Re: Short Circuit Logical Execution?"
- Previous message: Barbara: "Re: Run hidden Form"
- In reply to: Carl: "Re: Redim"
- Next in thread: Gerald Hernandez: "Re: Redim"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|