简体   繁体   中英

BufferedInputStream is throwing out-of-memory errors in Android

I'm trying to use a BufferedInputStream to load an external DICOM file, but it eventually runs out of memory. When I used an InputStream , this never came up (I did this when I was loading the file through the assets folder).

I created my own producer-consumer threads to buffer the file, so I don't actually need the BufferedInputStream, but I DO need to use mark() and reset() which is not available in FileInputStream .

How should I go around this? Is there another kind of InputStream that I can use with a File which has the mark() / reset() functions? Can I empty the buffer somehow before the BufferedInputStream throws the error? Or should I find a way around using mark() instead?

Thanks for your input.

For mark and reset to work with buffered input the file points between the mark and reset need to remain in memory.

Workarounds depend on what you're actually trying to do; if you just need to start reading from a known location, perhaps a RandomAccessFile .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM