Friday, 20 April 2007

JDK 6 to the rescue!

I have been trying to solve a File mapping issue while programming a Text Indexer. Due to the large size of the Lexicon (2.7 million terms, thanks to biwords!), I figured that my 512MB of RAM just ran out of space... and thus...

Exception in thread "main" java.io.IOException: Not enough space
at sun.nio.ch.FileChannelImpl.map0(Native Method)
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:742)
at Test.main(Test.java:18)
However, even 1GB and 2GB RAM machines were greeted with this!
Then after some searching... it turned out to be bug with Java's 1.5 run time environment and with just an upgrade to version 6.0, the code could run!

So if anyone who is still using JDK 5.0 or the JRE 5.0 remember the limitations when mapping files to memory! Also remember to buffer your File input and output streams if you're not using FileChannels!

Here is the bug report:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6417205

No comments: