-
Apr 30th, 2013, 06:23 AM
#1
Thread Starter
PowerPoster
out of memory during a loop of txt file
I use this routine to read txt file line by line...
i loop approx 123 files each file are of 45/80 MB. (approx 358.000 line per file)
i use (pseudo code):
...
for each file in my dir
TEST1(name_file )
next
...
Sub TEST1(name_file )
Dim temp As String
Dim MyArray() As String
Dim FileID As Integer
FileID = FreeFile
Open "C:\TEST\" & name_file For Binary Access Read As #FileID
temp = Space(LOF(FileID))
Get #FileID, , temp
Close #FileID
Erase MyArray()
MyArray() = Split(temp, vbNewLine)
temp = ""
Dim X As Long
For X = LBound(MyArray()) To UBound(MyArray())
temp = MyArray(X) 'Is the; current; Line
Next
End Sub
but after the 3thfile processed have Out of Memory!!!!
-
Apr 30th, 2013, 06:34 AM
#2
Re: out of memory during a loop of txt file
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Apr 30th, 2013, 07:18 AM
#3
Thread Starter
PowerPoster
Re: out of memory during a loop of txt file
Originally Posted by Bonnie West
ok tks!!!!
but in wich part of code i can loop "line by line" the array.... similar:
Dim X As Long
For X = LBound(MyArray()) To UBound(MyArray())
temp = MyArray(X) 'Is the; current; Line
Next
-
Apr 30th, 2013, 08:01 AM
#4
Re: out of memory during a loop of txt file
Can you post the relevant parts of your code? Your current For loop will have to be modified to properly work with that technique.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
May 1st, 2013, 06:47 AM
#5
Lively Member
Re: out of memory during a loop of txt file
Originally Posted by luca90
I use this routine to read txt file line by line...
i loop approx 123 files each file are of 45/80 MB. (approx 358.000 line per file)
...
but after the 3thfile processed have Out of Memory!!!!
You could look into changing some string to currency ?
clear some variables = null
look into converting dos/linux crlf/lf formatting required with some files.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|