Berkeley DB Reference Guide:
Memory Pool Subsystem

PrevRefNext

Berkeley DB and the memory pool

The Memory Pool subsystem is the general-purpose shared memory buffer pool used by Berkeley DB. This module is useful outside of the Berkeley DB package for processes that require page-oriented, cached, shared file access.

A memory pool is a memory cache shared among any number of threads of control. The DB_INIT_MPOOL flag to the DB_ENV->open interface opens, optionally creating a memory pool. When that pool is no longer in use, it should be closed using the DB_ENV->close interface.

The memp_fopen interface returns a DB_MPOOLFILE handle on an underlying file within the memory pool. When that handle is no longer in use, it should be closed using the memp_fclose interface. The memp_fget interface is used to retrieve pages from files in the pool. All retrieved pages must be subsequently returned using the memp_fput interface. At the time pages are returned, they may be marked dirty, which causes them to be written to the underlying file before being discarded from the pool. If there is insufficient room to bring a new page in the pool, a page is selected to be discarded from the pool using a least-recently-used algorithm. Pages in files may also be explicitly marked clean or dirty using the memp_fset interface. All dirty pages in the pool may be flushed using the memp_sync interface. All dirty pages in the pool from a single underlying file may be flushed using the memp_fsync interface.

There are additional interfaces related to the memory pool:


PrevRefNext

Copyright Sleepycat Software