Some applications, like mappers, benefit from caching chunks and regions locally. However, a fully loaded region can take up significant space in memory, which limits the usefulness of caches.
I'm proposing a mechanism for loading only the portions of a chunk or region that an application intends to use. Then, the internal reference to data in the chunks could be released to allow it to be garbage collected.
I propose something like this:
MCAFile::public void deserialize(RandomAccessFile raf, int fieldFlags) throws IOException
Some applications, like mappers, benefit from caching chunks and regions locally. However, a fully loaded region can take up significant space in memory, which limits the usefulness of caches.
I'm proposing a mechanism for loading only the portions of a chunk or region that an application intends to use. Then, the internal reference to
data
in the chunks could be released to allow it to be garbage collected.I propose something like this:
It would be used like this:
A chunk loaded this way cannot be written to disk and any attempt to do so should throw an exception.
If this seems OK, I will prepare a PR with the changes.