Debian Codegraph @

docs/api_reference/CXX/envset_cachesize.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>DbEnv::set_cachesize()</title>
7 <link rel="stylesheet" href="apiReference.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" />
10 <link rel="up" href="memp.html" title="Chapter 9.  The DbMpoolFile Handle" />
11 <link rel="prev" href="envset_cache_max.html" title="DbEnv::set_cache_max()" />
12 <link rel="next" href="mempset_mp_max_openfd.html" title="DbEnv::set_mp_max_openfd()" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">DbEnv::set_cachesize()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="envset_cache_max.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 9. 
26 The DbMpoolFile Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="mempset_mp_max_openfd.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="envset_cachesize"></a>DbEnv::set_cachesize()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 DbEnv::set_cachesize(u_int32_t gbytes, u_int32_t bytes, int ncache); </pre>
45 <p>
46 Sets the size of the shared memory buffer pool — that is, the cache.
47 The cache should be the size of the normal working data set of the
48 application, with some small amount of additional memory for unusual
49 situations. (Note: the working set is not the same as the number of
50 pages accessed simultaneously, and is usually much larger.)
51 </p>
52 <p>
53 The default cache size is 256KB, and may not be specified as less than
54 20KB. Any cache size less than 500MB is automatically increased by
55 25% to account for cache overhead; cache sizes larger than 500MB
56 are used as specified. The maximum size of a single cache is 4GB on
57 32-bit systems and 10TB on 64-bit systems. (All sizes are in
58 powers-of-two, that is, 256KB is 2^18 not 256,000.) For information on
59 tuning the Berkeley DB cache size, see
60 <a href="../../programmer_reference/general_am_conf.html#am_conf_cachesize" class="olink">Selecting a cache size</a>.
61 </p>
62 <p>
63 It is possible to specify caches to Berkeley DB large enough they
64 cannot be allocated contiguously on some architectures. For example,
65 some releases of Solaris limit the amount of memory that may be
66 allocated contiguously by a process. If <span class="bold"><strong>ncache</strong></span> is 0 or 1, the cache will be allocated
67 contiguously in memory. If it is greater than 1, the cache will be
68 split across <span class="bold"><strong>ncache</strong></span> separate regions,
69 where the <span class="bold"><strong>region size</strong></span> is equal to the
70 initial cache size divided by <span class="bold"><strong>ncache</strong></span>.
71 </p>
72 <p>
73 The cache may be resized by calling <code class="methodname">DbEnv::set_cachesize()</code>
74 after the environment is open. The supplied size will be rounded to the nearest multiple
75 of the region size and may not be larger than the maximum size configured with
76 <a class="xref" href="envset_cache_max.html" title="DbEnv::set_cache_max()">DbEnv::set_cache_max()</a>. The
77 <span class="bold"><strong>ncache</strong></span> parameter is ignored when resizing the cache.
78
79 </p>
80 <p>
81 The database environment's initial cache size may also be
82 configured using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The syntax of
83 the entry in that file is a single line with the string
84 "set_cachesize", one or more whitespace characters, and the
85 initial cache size specified in three parts: the gigabytes of
86 cache, the additional bytes of cache, and the number of caches,
87 also separated by whitespace characters. For example,
88 "set_cachesize 2 524288000 3" would create a 2.5GB logical cache,
89 split between three physical caches. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file
90 is read when the database environment is opened, it will silently
91 overrule configuration done before that time.
92 </p>
93 <p>
94 The <code class="methodname">DbEnv::set_cachesize()</code> method configures a database environment,
95 not only operations performed using the specified <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</a> handle.
96 </p>
97 <p>
98 The <code class="methodname">DbEnv::set_cachesize()</code> method may be called at any time during
99 the life of the application.
100 </p>
101 <p>
102 The <code class="methodname">DbEnv::set_cachesize()</code> <span>
103
104 <span>
105 method either returns a non-zero error value or throws an
106 exception that encapsulates a non-zero error value on
107 failure, and returns 0 on success.
108 </span>
109 </span>
110 </p>
111 <div class="sect2" lang="en" xml:lang="en">
112 <div class="titlepage">
113 <div>
114 <div>
115 <h3 class="title"><a id="idp8798512"></a>Parameters</h3>
116 </div>
117 </div>
118 </div>
119 <div class="sect3" lang="en" xml:lang="en">
120 <div class="titlepage">
121 <div>
122 <div>
123 <h4 class="title"><a id="idp8797864"></a>gbytes</h4>
124 </div>
125 </div>
126 </div>
127 <p>
128 The size of the cache is set to <span class="bold"><strong>gbytes</strong></span> gigabytes plus <span class="bold"><strong>bytes</strong></span>.
129 </p>
130 </div>
131 <div class="sect3" lang="en" xml:lang="en">
132 <div class="titlepage">
133 <div>
134 <div>
135 <h4 class="title"><a id="idp8788440"></a>bytes</h4>
136 </div>
137 </div>
138 </div>
139 <p>
140 The size of the cache is set to <span class="bold"><strong>gbytes</strong></span> gigabytes plus <span class="bold"><strong>bytes</strong></span>.
141 </p>
142 </div>
143 <div class="sect3" lang="en" xml:lang="en">
144 <div class="titlepage">
145 <div>
146 <div>
147 <h4 class="title"><a id="idp8784488"></a>ncache</h4>
148 </div>
149 </div>
150 </div>
151 <p>
152 The <span class="bold"><strong>ncache</strong></span> parameter is the number of
153 caches to create.
154 </p>
155 </div>
156 </div>
157 <div class="sect2" lang="en" xml:lang="en">
158 <div class="titlepage">
159 <div>
160 <div>
161 <h3 class="title"><a id="idp8788096"></a>Errors</h3>
162 </div>
163 </div>
164 </div>
165 <p>
166 The <code class="methodname">DbEnv::set_cachesize()</code> <span>
167
168 <span>
169 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
170 exception, encapsulating one of the following non-zero errors, or return one
171 of the following non-zero errors:
172 </span>
173 </span>
174 </p>
175 <div class="sect3" lang="en" xml:lang="en">
176 <div class="titlepage">
177 <div>
178 <div>
179 <h4 class="title"><a id="idp8813032"></a>EINVAL</h4>
180 </div>
181 </div>
182 </div>
183 <p>
184 If the specified cache size was impossibly small; or if an invalid
185 flag value or parameter was specified.
186 </p>
187 </div>
188 </div>
189 <div class="sect2" lang="en" xml:lang="en">
190 <div class="titlepage">
191 <div>
192 <div>
193 <h3 class="title"><a id="idp8810528"></a>Class</h3>
194 </div>
195 </div>
196 </div>
197 <p>
198 <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</a>
199 </p>
200 </div>
201 <div class="sect2" lang="en" xml:lang="en">
202 <div class="titlepage">
203 <div>
204 <div>
205 <h3 class="title"><a id="idp8806392"></a>See Also</h3>
206 </div>
207 </div>
208 </div>
209 <p>
210 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a>
211 </p>
212 </div>
213 </div>
214 <div class="navfooter">
215 <hr />
216 <table width="100%" summary="Navigation footer">
217 <tr>
218 <td width="40%" align="left"><a accesskey="p" href="envset_cache_max.html">Prev</a> </td>
219 <td width="20%" align="center">
220 <a accesskey="u" href="memp.html">Up</a>
221 </td>
222 <td width="40%" align="right"> <a accesskey="n" href="mempset_mp_max_openfd.html">Next</a></td>
223 </tr>
224 <tr>
225 <td width="40%" align="left" valign="top">DbEnv::set_cache_max() </td>
226 <td width="20%" align="center">
227 <a accesskey="h" href="index.html">Home</a>
228 </td>
229 <td width="40%" align="right" valign="top"> DbEnv::set_mp_max_openfd()</td>
230 </tr>
231 </table>
232 </div>
233 </body>
234 </html>