Berkeley DB Reference Version 5.3.33

DB_ENV->set_memory_init()

#include <db.h>

int
DB_ENV->set_memory_init(DB_ENV *dbenv, DB_MEM_CONFIG type, 
                        u_int32_t count);  

This method sets the number of objects to allocate and initialize for a specified structure when an environment is created. Doing this helps avoid memory contention after startup. Using this method is optional; failure to use this method causes BDB to allocate a minimal number of structures that will grow dynamically. These structures are all allocated from the main environment region. The amount of memory in this region can be set via the DB_ENV->set_memory_max() method. If this method is not called then memory will be limited to the initial settings or by the (deprecated) set maximum interfaces.

The database environment's initialization may also be configured using the environment's DB_CONFIG file. The syntax of the entry in that file is a single line with the string "set_memory_init", one or more whitespace characters, followed by the struct specification, more white space and the count to be allocated. Because the DB_CONFIG file is read when the database environment is opened, it will silently overrule configuration done before that time.

The DB_ENV->set_memory_init() method must be called prior to opening the database environment. It may be called as often as needed to set the different configurations.

Parameters

type

The type parameter must be set to one of the following:

count

The count parameter sets the number of specified objects to initialize.

The count specified for locks and lock objects should be at least 5 times the number of lock table partitions. You can examine the current number of lock table partitions configured for your environment using the DB_ENV->get_lk_partitions() method.

Errors

The DB_ENV->set_memory_init() method may fail and return one of the following non-zero errors:

EINVAL

If the method was called after DB_ENV->open() was called; or if an invalid flag value or parameter was specified.

Class

DB_ENV

See Also

Database Environments and Related Methods