### Berkeley DB Reference Guide: Memory Pool Subsystem |

# Configuring the memory pool

There are two interfaces used for configuring the memory pool.

The most important tuning parameter for almost all applications, including Berkeley DB applications, is the size of the pool. There are two ways to specify the pool size. First, calling the DBENV->set_cachesize function specifies the pool size for all of the applications sharing the Berkeley DB environment. Second, by calling the DB->set_cachesize function. The latter only specifies a pool size for the specific database. Note, it is meaningless to call DB->set_cachesize for a database opened inside of a Berkeley DB environment, since the environment pool size will override any pool size specified for a single database. For information on tuning the Berkeley DB cache size, see Selecting a cache size.

The second memory pool configuration interface specifies the maximum size of backing files to map into the process address space instead of copying pages through the local cache. Only read-only database files can be mapped into process memory. Because of the requirements of the Berkeley DB transactional implementation, log records describing database changes must be written to disk before the actual database changes. As mapping read-write database files into process memory would permit the underlying operating system to write modified database changes at will, it is not supported.

Mapping files into the process address space can result in better-than-usual performance, as available virtual memory is normally much larger than the local cache, and page faults are faster than page copying on many systems. However, in the presence of limited virtual memory it can cause resource starvation, and in the presence of large databases, it can result in immense process sizes.

To specify that no files are to be mapped into the process address space, specify the DB_NOMMAP flag to the DBENV->open interface. To specify that any individual file should not be mapped into the process address space, specify the DB_NOMMAP flag to the memp_fopen interface. To limit the size of files mapped into the process address space, use the DBENV->set_mp_mmapsize function.

Copyright Sleepycat Software