-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't hold the underlying file/channel open for longer than necessary. #7
Don't hold the underlying file/channel open for longer than necessary. #7
Conversation
When loading from a database, once read and/or mapped the file/channel can be safely closed. (Even when using MEMORY_MAPPED, once we have the mapped buffer the original file can be safely closed without affecting the buffer.)
Thanks. You are right. We should probably just get rid of the Closeable interface. At one point, there was a plan to create a non-mmap file mode, but there hasn't been much demand. |
The same occurred to me. However before discarding it entirely I thought there might be a way to mitigate the problem you've identified on Windows with the mapping. Specifically, right now (before and after this pull request), My dev platform isn't Windows, but is this something that would interest you? If not, I can refine this pull request by removing the |
I like that suggestion as it doesn't require an API change, and it does provide some utility to the |
Right. I'll leave this pull-request as-is then (and ready for merge, I hope) and code the |
threw = false; | ||
} finally { | ||
try { | ||
// Also closes the underlying channel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this documented somewhere? My Google searches suggest that this may depend on the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for RandomAccessFile.close()
has included the following since Java 1.4:
If this file has an associated channel then the channel is closed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. 👍 I must have totally glossed over that.
I released 0.3.4 with the changes. |
Thanks; much appreciated! |
Thank you! |
When loading from a database, once read and/or mapped the file/channel can be safely closed.
(Even when using MEMORY_MAPPED, once we have the mapped buffer the original file can be safely closed without affecting the buffer.)