# Monday, April 9, 2007
« New Snapshot | Main | Detecting .NET 2.0 x64 »
Memory Mapped Files

What happens when you get a read error while accessing a memory mapped file? Let's try it:

RandomAccessFile raf = new RandomAccessFile("\\\\server\\share\\filename", "r");
FileChannel channel = raf.getChannel();
MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0, 5 * 1024 * 1024);
map.get(10 * 1024);
System.out.println("read byte at 10K -- waiting");
map.get(500 * 1024);
System.out.println("read byte at 500K");

Running this on JDK 1.6 (x64) and removing the network cable during the sleep will result in an Internal Error in the VM. Not exactly what I had hoped for.

Interestingly, on IKVM doing the same results in a cli.System.Runtime.InteropServices.SEHException being thrown.

Monday, April 9, 2007 11:32:31 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [1]
Monday, April 9, 2007 7:25:33 PM (W. Europe Daylight Time, UTC+02:00)
When you see this problem with jdk6 do you get a EXCEPTION_IN_PAGE_ERROR? If so, then the issue is likely to be http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6415680
Comments are closed.