Hello,
i wrote a simple code to read a big csv-file line-by-line following this example:
http://www.b4x.com/android/forum/threads/parsing-huge-text-files.34923/
Here is my code:
after ~ 270.000 lines i get this error:
I thought, reading a file line-by-line wouldn't increase the memory consumption.
What did I do wrong?
Thanks in advance & Greetings ... Kiffi (Windows Vista Business / 32 Bit / 4 GB RAM)
i wrote a simple code to read a big csv-file line-by-line following this example:
http://www.b4x.com/android/forum/threads/parsing-huge-text-files.34923/
Here is my code:
B4X:
Dim myTextReader As TextReader
Try
' big.csv (266 MB ~ 790.000 lines)
myTextReader.Initialize(File.OpenInput("D:\data\", "big.csv") )
Dim LineCounter As Int = 0
Dim line As String = myTextReader.ReadLine
Do While line <> Null
LineCounter = LineCounter + 1
line = myTextReader.ReadLine
If LineCounter Mod 10000 = 0 Then
Log("Line: " & NumberFormat(LineCounter, 0, 0))
End If
Loop
myTextReader.Close
Catch
Log("Error --> " & LastException.Message)
If myTextReader.IsInitialized Then
myTextReader.Close
End If
End Try
after ~ 270.000 lines i get this error:
log said:Program started.
Line: 10,000
[..]
Line: 270,000
Exception in runnable
java.lang.OutOfMemoryError: Java heap space
I thought, reading a file line-by-line wouldn't increase the memory consumption.
What did I do wrong?
Thanks in advance & Greetings ... Kiffi (Windows Vista Business / 32 Bit / 4 GB RAM)