summaryrefslogtreecommitdiff
path: root/docs/upgrading/upgrade_4_3_enomem.html
blob: 5fc4f427f84694f942ce403350e3e7a9e7fc5b4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>ENOMEM and DbMemoryException</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Berkeley DB Upgrade Guide" />
    <link rel="up" href="upgrade_4_3_toc.html" title="Chapter 7. Upgrading Berkeley DB 4.2 applications to Berkeley DB 4.3" />
    <link rel="prev" href="upgrade_4_3_fileopen.html" title="DB_FILEOPEN" />
    <link rel="next" href="upgrade_4_3_repl.html" title="Replication" />
  </head>
  <body>
    <div xmlns="" class="navheader">
      <div class="libver">
        <p>Library Version 12.1.6.1</p>
      </div>
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">ENOMEM and DbMemoryException</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="upgrade_4_3_fileopen.html">Prev</a> </td>
          <th width="60%" align="center">Chapter 7. Upgrading Berkeley DB 4.2 applications to Berkeley DB 4.3</th>
          <td width="20%" align="right"> <a accesskey="n" href="upgrade_4_3_repl.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a id="upgrade_4_3_enomem"></a>ENOMEM and DbMemoryException</h2>
          </div>
        </div>
      </div>
      <p>In versions of Berkeley DB before 4.3, the error <span class="bold"><strong>ENOMEM</strong></span> was used to
indicate that the buffer in a <a href="../api_reference/C/dbt.html" class="olink">DBT</a> configured with
<a href="../api_reference/C/dbt.html#dbt_DB_DBT_USERMEM" class="olink">DB_DBT_USERMEM</a> was too small to hold a key or data item being
retrieved.  The 4.3 release adds a new error, <code class="literal">DB_BUFFER_SMALL</code>,
that is returned in this case.</p>
      <p>The reason for the change is that the use of <span class="bold"><strong>ENOMEM</strong></span> was
ambiguous: calls such as <a href="../api_reference/C/dbget.html" class="olink">DB-&gt;get()</a> or <a href="../api_reference/C/dbcget.html" class="olink">DBC-&gt;get()</a> could return
<span class="bold"><strong>ENOMEM</strong></span> either if a <a href="../api_reference/C/dbt.html" class="olink">DBT</a> was too small or if some resource
was exhausted.</p>
      <p>The result is that starting with the 4.3 release, C applications should
always treat <span class="bold"><strong>ENOMEM</strong></span> as a fatal error.  Code that checked for
the <span class="bold"><strong>ENOMEM</strong></span> return and allocated a new buffer should be changed
to check for <code class="literal">DB_BUFFER_SMALL</code>.</p>
      <p>
    In C++ applications configured for exceptions, a 
    <a href="../api_reference/CXX/dbmemory.html" class="olink">DbMemoryException</a>
    will continue to be thrown in both cases, and applications should check
    the errno in the exception to determine which error occurred.
</p>
      <p>In Java applications, a <span class="bold"><strong>DbMemoryException</strong></span> will be thrown when a <span class="bold"><strong>Dbt</strong></span> is too small to hold a return value, and an <span class="bold"><strong>OutOfMemoryError</strong></span> will be thrown in all cases of resource exhaustion.</p>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="upgrade_4_3_fileopen.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="upgrade_4_3_toc.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="upgrade_4_3_repl.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">DB_FILEOPEN </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Replication</td>
        </tr>
      </table>
    </div>
  </body>
</html>