I have an application which reads a 70 Mb text file (compressed into a 5 Mb file).
The problem is, that it takes initially 256 Mb to read the file (with this code):Later, it grows up to 720 Mb!Code:Public Function CompressedFileToStringArray(ByVal FilePath As String) As String() Dim Answer() As String Try Dim fs As FileStream = File.OpenRead(FilePath) Dim GZfs As New GZipStream(fs, CompressionMode.Decompress, False) Dim sr As New StreamReader(GZfs) Answer = sr.ReadToEnd.Split(vbCrLf.ToCharArray, StringSplitOptions.RemoveEmptyEntries) fs.Close() Catch Throw New Exception _ ("Error en Function L*neasDeArchivo" & vbCrLf & _ "no se pudo abrir:" & vbCrLf & _ FilePath) End Try Return Answer End Function
¿Some idea on how to reduce the memory footprint?




Reply With Quote