问题
I was working with LMDB++ (the C++ wrapper for LMDB) and I got this error:
terminate called after throwing an instance of 'lmdb::map_full_error'
what(): mdb_put: MDB_MAP_FULL: Environment mapsize limit reached
Some googling told me that the default map_size is set low in LMDB. How do I go about increasing map_size?
回答1:
The default LMDB map size is 10 MiB, which is indeed too small for most uses.
To set the LMDB map size using the C++ wrapper, you ought to call lmdb::env#set_mapsize()
right after creating your LMDB environment and prior to opening the environment or creating your transaction.
Here's a basic example that increases the map size to 1 GiB:
/* Create and open the LMDB environment: */
auto env = lmdb::env::create();
env.set_mapsize(1UL * 1024UL * 1024UL * 1024UL);
env.open("./example.mdb", 0, 0664);
If you are calculating a large map size as in the above example, take care to include the appropriate type suffix (UL
or ULL
) on your integer literals, or else you may encounter silent integer overflow and be left wondering why the map size did not increase to what you expected.
See also the documentation for LMDB's underlying C function mdb_env_set_mapsize() for the authoritative word on how the map size works.
来源:https://stackoverflow.com/questions/31820976/lmdb-increase-map-size