DbEnv::set_cachesize(u_int32_t gbytes, u_int32_t bytes, int ncache); </pre>
<p>
Sets the size of the shared memory buffer pool — that is, the cache.
The cache should be the size of the normal working data set of the
application, with some small amount of additional memory for unusual
situations. (Note: the working set is not the same as the number of
pages accessed simultaneously, and is usually much larger.)
</p>
<p>
The default cache size is 256KB, and may not be specified as less than
20KB. Any cache size less than 500MB is automatically increased by
25% to account for cache overhead; cache sizes larger than 500MB
are used as specified. The maximum size of a single cache is 4GB on
32-bit systems and 10TB on 64-bit systems. (All sizes are in
powers-of-two, that is, 256KB is 2^18 not 256,000.) For information on
tuning the Berkeley DB cache size, see
<ahref="../../programmer_reference/general_am_conf.html#am_conf_cachesize"class="olink">Selecting a cache size</a>.
</p>
<p>
It is possible to specify caches to Berkeley DB large enough they
cannot be allocated contiguously on some architectures. For example,
some releases of Solaris limit the amount of memory that may be
allocated contiguously by a process. If <spanclass="bold"><strong>ncache</strong></span> is 0 or 1, the cache will be allocated
contiguously in memory. If it is greater than 1, the cache will be
split across <spanclass="bold"><strong>ncache</strong></span> separate regions,
where the <spanclass="bold"><strong>region size</strong></span> is equal to the
initial cache size divided by <spanclass="bold"><strong>ncache</strong></span>.
</p>
<p>
The cache may be resized by calling <codeclass="methodname">DbEnv::set_cachesize()</code>
after the environment is open. The supplied size will be rounded to the nearest multiple
of the region size and may not be larger than the maximum size configured with
<aclass="xref"href="envset_cache_max.html"title="DbEnv::set_cache_max()">DbEnv::set_cache_max()</a>. The
<spanclass="bold"><strong>ncache</strong></span> parameter is ignored when resizing the cache.
</p>
<p>
The database environment's initial cache size may also be
configured using the environment's <ahref="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG"class="olink">DB_CONFIG</a> file. The syntax of
the entry in that file is a single line with the string
"set_cachesize", one or more whitespace characters, and the
initial cache size specified in three parts: the gigabytes of
cache, the additional bytes of cache, and the number of caches,
also separated by whitespace characters. For example,
"set_cachesize 2 524288000 3" would create a 2.5GB logical cache,
split between three physical caches. Because the <ahref="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG"class="olink">DB_CONFIG</a> file
is read when the database environment is opened, it will silently
overrule configuration done before that time.
</p>
<p>
The <codeclass="methodname">DbEnv::set_cachesize()</code> method configures a database environment,
not only operations performed using the specified <aclass="link"href="env.html"title="Chapter5. The DbEnv Handle">DbEnv</a> handle.
</p>
<p>
The <codeclass="methodname">DbEnv::set_cachesize()</code> method may be called at any time during
the life of the application.
</p>
<p>
The <codeclass="methodname">DbEnv::set_cachesize()</code><span>
<span>
method either returns a non-zero error value or throws an
exception that encapsulates a non-zero error value on