OutOfMemoryError exception when using Bufferedinputstream
OutOfMemoryError exception when using Bufferedinputstream.
In order for InputStream to be read repeatedly, we will decorate a InputStream instance with Bufferedinputstream.
New Bufferedinputstream (IS); Bis.mark (integer.max_value); // While bis.read (...) Bis.reset
It's actually bufferedinputstream to save the data after Mark and restore it when reset is called, so when there's too much inputstream data, there's a problem, especially when I do Android development on my phone, and when the data is over 13K, It is possible that there is not enough memory to throw down the following exception:
while executing doinbackground () ...... caused by:java.lang.OutOfMemoryError at java.io.BufferedInputStream.fillbuf (Bufferedinputstream.java: 156) at java.io.BufferedInputStream.read (Bufferedinputstream.java:309) at Java.io.InputStream.read (Inputstream.java:163) at ...
Therefore, the Mark method requires that the maximum number of bytes to be recorded should not be set as Integer.max_value.
Summary of "Javase" Java issues