Major rewrite after discovering that mmap can use huge amounts of memory. During writing, a separate index file is created. This file is updated using mmap, while the main data file just uses normal file operations. When the file is closed after a write operation, it is appended to the end of the main data file. When open for reading, mmap is only used on the index at the end of the file.
There's still the issue that when the number of indexes increases to over 100,000 and upwards of 1,000,000 there is significant slowdown due to the constant moving/copying of indexes during insertions. mmap is currently handling this, and I haven't figured out a decent way to create an indexing system without moving data around...