888box
888box

Reputation: 31

LMDB maximum size of the database for windows

When I set the maximum db size to be, for example, 5G, on windows the final db file size will become 5G even I only insert one small piece of data. But on linux it works fine, the final db size is related with how many data I insert into.

Here's the api I used to set maximum db size

rc = ::mdb_env_set_mapsize(env, 5 * 1024 * 1024 * 1024);

Same for Windows and linux. Do I need to do something different for windows?

Upvotes: 3

Views: 4102

Answers (1)

hyc
hyc

Reputation: 1443

That's how memory-mapped files work on Windows - if you want a map of size xxGB, Windows requires the file to be of size xxGB. Windows grows the file itself if the file was originally smaller than the specified size; there is no way around this.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa366542%28v=vs.85%29.aspx

NTFS can support sparse files, but in testing we found that Windows sparse file support is significantly slower than normal files, so LMDB doesn't use it.

Upvotes: 5

Related Questions