Skip to content

Commit 68a20c3

Browse files
committed
Added a comment about file locking and MMAP on Windows
1 parent cf24286 commit 68a20c3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ This API fully supports use in multi-threaded applications. In such
6969
applications, we suggest creating one `Reader` object and sharing that among
7070
threads.
7171

72+
## Common Problems ##
73+
74+
### File Lock on Windows ###
75+
76+
By default, this API uses the `MEMORY_MAP` mode, which memory maps the file.
77+
On Windows, this may create an exclusive lock on the file that prevents it
78+
from being renamed or deleted. Due to the implementation of memory mapping in
79+
Java, this lock will not be released when the `DatabaseReader` is closed; it
80+
will only be released when the object and the `MappedByteBuffer` it uses are
81+
garbage collected. Older JVM versions may also not release the lock on exit.
82+
83+
To work around this problem, use the `MEMORY` mode or try upgrading your JVM
84+
version. You may also call `System.gc()` after dereferencing the
85+
`DatabaseReader` object to encourage the JVM to garbage collect sooner.
86+
7287
## Format ##
7388

7489
The MaxMind DB format is an open format for quickly mapping IP addresses to

0 commit comments

Comments
 (0)