What I'm using is a List<ByteBuffer> , where each ByteBuffer maps a file in a block from 16 MB to 1 GB. I use powers of 2 to simplify the logic. I used this to display in files up to 8 TB.
A key limitation of memory mapped files is that you are limited by your virtual memory. If you have a 32-bit JVM, you will not be able to display it very much.
I would not create new memory mappings for a file because they are never cleared. You can create many of them, but it seems that their limit is around 32 KB on some systems (no matter how small they are)
The main reason I find MemoryMappedFiles useful is that they donβt need to be cleaned up (if you can assume that the OS will not die) This allows you to record low latency data without worrying about losing too much data. if the application dies or has too much performance, having to write () or flash ().
source share