DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

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, shared and cached 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 method opens and optionally creates a memory pool. When that pool is no longer in use, it should be closed using the DB_ENV->close method.

The DB_ENV->memp_fcreate method returns a DB_MPOOLFILE handle on an underlying file within the memory pool. The file may be opened using the DB_MPOOLFILE->open method. The DB_MPOOLFILE->get method is used to retrieve pages from files in the pool. All retrieved pages must be subsequently returned using the DB_MPOOLFILE->put method. 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 DB_MPOOLFILE->set method. All dirty pages in the pool from the file may be flushed using the DB_MPOOLFILE->sync method. When the file handle is no longer in use, it should be closed using the DB_MPOOLFILE->close method.

There are additional configuration interfaces that apply when opening a new file in the memory pool:

There are additional interfaces for the memory pool as a whole:

Memory Pools and Related MethodsDescription
DB->get_mpfReturn the database's memory pool handle
DB_ENV->memp_statReturn memory pool statistics
DB_ENV->memp_syncFlush pages from a memory pool
DB_ENV->memp_trickleTrickle flush pages from a memory pool
Memory Pool Configuration
DB_ENV->memp_registerRegister input/output functions for a file in a memory pool
DB_ENV->set_cachesizeSet the environment cache size
DB_ENV->set_mp_max_openfdSet the maximum number of open file descriptors
DB_ENV->set_mp_max_writeSet the maximum number of sequential disk writes
DB_ENV->set_mp_mmapsizeSet maximum mapped-in database file size
Memory Pool Files
DB_ENV->memp_fcreateCreate a memory pool file handle
DB_MPOOLFILE->closeClose a file in a memory pool
DB_MPOOLFILE->getGet page from a file in a memory pool
DB_MPOOLFILE->openOpen a file in a memory pool
DB_MPOOLFILE->putReturn a page to a memory pool
DB_MPOOLFILE->setSet memory pool page attributes
DB_MPOOLFILE->syncFlush pages from a file in a memory pool
Memory Pool File Configuration
DB_MPOOLFILE->set_clear_lenSet file page bytes to be cleared
DB_MPOOLFILE->set_fileidSet file unique identifier
DB_MPOOLFILE->set_flagsGeneral memory pool file configuration
DB_MPOOLFILE->set_ftypeSet file type
DB_MPOOLFILE->set_lsn_offsetSet file log-sequence-number offset
DB_MPOOLFILE->set_maxsizeSet maximum file size
DB_MPOOLFILE->set_pgcookieSet file cookie for pgin/pgout
DB_MPOOLFILE->set_prioritySet memory pool file priority

PrevRefNext

Copyright (c) 1996-2005 Sleepycat Software, Inc. - All rights reserved.