私はStreamReader
大きなテキストファイル(〜300 MB)で を使用しており、ループで ReadLine() を呼び出すと、最終的に奇妙な がスローされますArgumentOutOfRangeException
:
Index and count must refer to a location within the buffer.
Parameter name: bytes
スタックトレースは次のとおりです。
at System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount,
Char[] chars, Int32 charIndex, Boolean flush)
at System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount,
Char[] chars, Int32 charIndex)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
....
これは奇妙なメモリエラーですか?投げないOutOfMemoryException
ので少し迷っています。2000行目あたりで発生します。その時までに、ReadLine() が成功したとしても、他の場所で奇妙な例外をスローし始めます。おそらくどこかでメモリ リークが発生していると思われますが、特定の箇所ReadLine()
やStreamReader
確認すべき箇所はありますか?
テキスト ファイルの各行の長さは、正確に 24 文字です。