# 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
Home page

I apologize for the lameness of this, but the comment spam was driving me nuts. In order to be able to post a comment, you need to answer a simple question. Hopefully this question is easy enough not to annoy serious commenters, but hard enough to keep the spammers away.

Anti-Spam Question: What method on java.lang.System returns an object's original hashcode (i.e. the one that would be returned by java.lang.Object.hashCode() if it wasn't overridden)? (case is significant)

Comment (HTML not allowed)  

Live Comment Preview