Thanks for responding. Unfortunately, I am not familiar w/ stacks. I am not
doing anything in my code to specifically direct it regarding using stacks.
How can I find out more about this.
You talk about checking the data limitation in the onlilne manual. Win95 is
pretty weak on documentation. Could you give me an example of what that
would be on platforms w/ which you are more familiar?
On the rediming...I agree that this must be very memory intensive. The only
approach I can think of that would avoid this is to run through my text file
using the .readline or, better yet, .skip and keep a variable to tally the
total number of lines before I start populating my array. But, this means I
have to run through the file twice. Is there another way that may be more
efficient that I'm not thinking about? Would a Dictionary w/ the Key = line
number and Value = line of text be more efficient?
Thanks,
Paul
-----Original Message-----
From: Marco Straforini [mailto:marco.straforini@c...]
Sent: Friday, September 28, 2001 6:23 PM
To: professional vb
Subject: [pro_vb] RE: Inconsistent Error 7 Out of memory
This is interesting.
You are allocating an array of 9x40,000 Variants, each Variant is a 12 bytes
so you have a total of circa 5MB. Unless your array is in the stack (it is
not clear from your code) that is limited to 1MB you should not have
problems.
I do not know W95 though... Do you have a task manager in Win95 to check for
memory usage? Did you check the Data Limitation page of the online manual?
You are redim'ing (and preserve) your array at every line read from the
file.
This operation is quite expensive. I would change your code to get the
number of lines in the file, redim the array in one shot (with no preserve)
and then read the file line by line.
Let me know,
m.
-----Original Message-----
From: Paul Engel [mailto:pengel@s...]
Sent: Friday, September 28, 2001 2:15 PM
To: professional vb
Subject: [pro_vb] Inconsistent Error 7 Out of memory
I have an application that is developed under Win2K (VB6, sp5), then
compiled on my client's Win95 (also SP5) computer. One of its tasks is to
read a file into a two dimensional array based on the values in each
delimited line in of text in the file. The file is over 35,000 lines. I have
my variables declared as long, so I shouldn't have an integer problem.
(Plus, the problems aren't around the integer limit, 32,767.) The array in
questions is declared as a Variant. I am using enumerators as the first
dimension in my array. (I ran the program w/ no problems before moving to
the enumeration...which I really like. I am wondering if that could be
contributing?) The program works perfectly on my Win2K machine.
Here is the problem. When I run the program on my client's machine, it bombs
out. BUT, it bombs out at different lines of the text file. Today it died at
line 30,462, twice at 30,459 and once at 40,429. I get a run time error 7,
out of memory. I think the machine has 256M of RAM. (I should have checked
for sure, but I'm pretty sure.) So, memory shouldn't be a problem.
It is crashing at a redim preserve instruction. I have included the relevant
code below w/ a string of asterisks at the point of failure. If anyone has
any ideas, please pass them along.
Regards,
Paul
-----------code excerpt --------------------
' Open source file list
Set fsoSourceFileList
fso.OpenTextFile(arrFileList(enumFileList.MasterList))
lngLinesInFile = -1
lngDocumentsInFile = -1
lblNumberOfFiles.Caption = "Calculating..."
lblNumberOfFiles.Refresh
' Loop through file
Do While Not fsoSourceFileList.AtEndOfStream
' Increment the line counter for redim purposes
lngLinesInFile = lngLinesInFile + 1
' Update form label
lblWorkingFile.Caption = lngLinesInFile + 1
lblWorkingFile.Refresh
' Redim retain array to a 7,1 array
ReDim Preserve arrPage(8, lngLinesInFile)
'*****************************************
' Split into array
arrSplitText = Split(fsoSourceFileList.ReadLine, ",")
' Post to array
arrPage(enumPage.PageID, lngLinesInFile) = arrSplitText(0)
arrPage(enumPage.FileName, lngLinesInFile) = arrSplitText(2)
arrPage(enumPage.FirstPageIndicator, lngLinesInFile) = arrSplitText(3)
Loop