1<!--$Id: db_set_cachesize.so,v 10.21 2002/08/18 21:15:53 bostic Exp $--> 2<!--$Id: env_set_cachesize.so,v 10.51 2007/07/06 00:22:52 mjc Exp $--> 3<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 4<!--See the file LICENSE for redistribution information.--> 5<html> 6<head> 7<title>Berkeley DB: DB->set_cachesize</title> 8<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 9<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 10</head> 11<body bgcolor=white> 12<table width="100%"><tr valign=top> 13<td> 14<b>DB->set_cachesize</b> 15</td> 16<td align=right> 17<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a> 18<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 19</tr></table> 20<hr size=1 noshade> 21<tt> 22<b><pre> 23#include <db.h> 24<p> 25int 26DB->set_cachesize(DB *db, 27 u_int32_t gbytes, u_int32_t bytes, int ncache); 28<p> 29int 30DB->get_cachesize(DB *db, 31 u_int32_t *gbytesp, u_int32_t *bytesp, int *ncachep); 32</pre></b> 33<hr size=1 noshade> 34<b>Description: DB->set_cachesize</b> 35<p>Set the size of the shared memory buffer pool -- that is, the cache. 36The cache should be the size of the normal working data set of the 37application, with some small amount of additional memory for unusual 38situations. (Note: the working set is not the same as the number of 39pages accessed simultaneously, and is usually much larger.)</p> 40<p>The default cache size is 256KB, and may not be specified as less than 4120KB. Any cache size less than 500MB is automatically increased by 25% 42to account for buffer pool overhead; cache sizes larger than 500MB are 43used as specified. The maximum size of a single cache is 4GB on 32-bit 44systems and 10TB on 64-bit systems. (All sizes are in powers-of-two, 45that is, 256KB is 2^18 not 256,000.) For information on tuning the Berkeley DB 46cache size, see <a href="../ref/am_conf/cachesize.html">Selecting a 47cache size</a>.</p> 48<p>It is possible to specify caches to Berkeley DB large enough they cannot be 49allocated contiguously on some architectures. For example, some 50releases of Solaris limit the amount of memory that may be allocated 51contiguously by a process. If <b>ncache</b> is 0 or 1, the cache will 52be allocated contiguously in memory. If it is greater than 1, the cache 53will be split across <b>ncache</b> separate regions, where the 54<b>region size</b> is equal to the initial cache size divided by 55<b>ncache</b>.</p> 56<p>Because databases opened within Berkeley DB environments use the cache 57specified to the environment, it is an error to attempt to set a cache 58in a database created within an environment.</p> 59<p>The DB->set_cachesize method may not be called after the <a href="../api_c/db_open.html">DB->open</a> method is called. 60</p> 61<p>The DB->set_cachesize method 62returns a non-zero error value on failure 63and 0 on success. 64</p> 65<b>Parameters</b> <br> 66 <b>bytes</b><ul compact><li>The size of the cache is set to <b>gbytes</b> gigabytes plus <b>bytes</b>.</ul> 67 <b>gbytes</b><ul compact><li>The size of the cache is set to <b>gbytes</b> gigabytes plus <b>bytes</b>.</ul> 68 <b>ncache</b><ul compact><li>The <b>ncache</b> parameter is the number of caches to create.</ul> 69<br> 70<br><b>Errors</b> 71<p>The DB->set_cachesize method 72may fail and return one of the following non-zero errors:</p> 73<br> 74<b>EINVAL</b><ul compact><li>If the specified cache size was impossibly small; 75the method was called after 76<a href="../api_c/db_open.html">DB->open</a> was called; or if an 77invalid flag value or parameter was specified.</ul> 78<br> 79<hr size=1 noshade> 80<b>Description: DB->get_cachesize</b> 81<p>The DB->get_cachesize method returns the current size and composition of the 82cache.</p> 83<p>The DB->get_cachesize method may be called at any time during the life of the 84application.</p> 85<p>The DB->get_cachesize method 86returns a non-zero error value on failure 87and 0 on success. 88</p> 89<b>Parameters</b> <br> 90 <b>bytesp</b><ul compact><li>The <b>bytesp</b> parameter references memory into which 91 the additional bytes of memory in the cache is copied.</ul> 92 <b>gbytesp</b><ul compact><li>The <b>gbytesp</b> parameter references memory into which 93 the gigabytes of memory in the cache is copied.</ul> 94 <b>ncachep</b><ul compact><li>The <b>ncachep</b> parameter references memory into which 95 the number of caches is copied.</ul> 96<br> 97<hr size=1 noshade> 98<br><b>Class</b> 99<a href="../api_c/db_class.html">DB</a> 100<br><b>See Also</b> 101<a href="../api_c/db_list.html">Databases and Related Methods</a> 102</tt> 103<table width="100%"><tr><td><br></td><td align=right> 104<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 105</td></tr></table> 106<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 107</body> 108</html> 109