mdb_env_set_mapsize function

int mdb_env_set_mapsize(
  1. Pointer<MDB_env> env,
  2. int size
)

@brief Set the size of the memory map to use for this environment.

The size should be a multiple of the OS page size. The default is 10485760 bytes. The size of the memory map is also the maximum size of the database. The value should be chosen as large as possible, to accommodate future growth of the database. This function should be called after #mdb_env_create() and before #mdb_env_open(). It may be called at later times if no transactions are active in this process. Note that the library does not check for this condition, the caller must ensure it explicitly.

The new size takes effect immediately for the current process but will not be persisted to any others until a write transaction has been committed by the current process. Also, only mapsize increases are persisted into the environment.

If the mapsize is increased by another process, and data has grown beyond the range of the current mapsize, #mdb_txn_begin() will return #MDB_MAP_RESIZED. This function may be called with a size of zero to adopt the new size.

Any attempt to set a size smaller than the space already consumed by the environment will be silently changed to the current size of the used space. @paramin env An environment handle returned by #mdb_env_create() @paramin size The size in bytes @return A non-zero error value on failure and 0 on success. Some possible errors are:

  • EINVAL - an invalid parameter was specified, or the environment has an active write transaction.

Implementation

@ffi.FfiNative<ffi.Int Function(ffi.Pointer<MDB_env>, mdb_size_t)>(
    'mdb_env_set_mapsize')
external int mdb_env_set_mapsize(
  ffi.Pointer<MDB_env> env,
  int size,
);