java.io.IOException: Map failed
at solar.nio.ch.FileChannelImpl.map(FileChannelImpl.java:888)
Attributable to: java.lang.OutOfMemoryError: Map failed
at solar.nio.ch.FileChannelImpl.map0(Native Technique)
at solar.nio.ch.FileChannelImpl.map(FileChannelImpl.java:885)
… 6 extra
How you can Clear up java.io.IOException: Map failed
Relying upon which working system you’re working, like Home windows or UNIX, you’ll be able to strive various things to unravel this error. One of many fast methods to unravel that is by decreasing the scale, which you need to map into reminiscence.
For instance, in case you are attempting to map 1GB into reminiscence, you might need to solely map 512MB or decrease, in case your code makes use of a region-based method, this may occasionally work file.
By the best way, if you do not know or have confusion how precisely reminiscence mapped file work and the way it can entry reminiscence outdoors the JVM then here’s a good diagram which explains that to you:
Alternatively, you can even use -d64 and -XX:MaxDirectMemorySize JVM choice to allow massive direct buffers :
-d64
This JVM flag instructs the digital machine to run on 64-bit mode. Since 64-bit set up on Solaris and perhaps on different UNIX programs comes with 32-bit JVM as nicely, which can be environment friendly for small applications, as a consequence of small dimension of OOPS pointer as discusses on why use -XX:UseCompressedOOPS flag in 64-bit JVM. By offering this feature to your JVM you be sure that it is operating on 64-bit mode, permitting it to map extra reminiscence.
-XX:MaxDirectMemorySize
This selection is just not on the official checklist of JVM flags however continues to be a great choice to strive. It means that you can configure reminiscence utilized by direct buffers.
Yet another choice, you’ll be able to strive is -XX:+UseLargePages.
For instance, in case your program is utilizing 6GB of memory-mapped file, you might need to move
$ java -d64 -XX:MaxDirectMemorySize=6g -XX:+UseLargePages BigApp
That is all on methods to clear up java.io.IOException: Map failed and java.lang.OutOfMemoryError: Map failed. You need to use any of those choices or a mixture of them to see what works for you. Ensure you use 64-bit JVM in case you are mapping massive information in reminiscence.