<h2class="title"style="clear: both"><aid="upgrade_4_3_enomem"></a>ENOMEM and DbMemoryException</h2>
</div>
</div>
</div>
<p>In versions of Berkeley DB before 4.3, the error <spanclass="bold"><strong>ENOMEM</strong></span> was used to
indicate that the buffer in a <ahref="../api_reference/C/dbt.html"class="olink">DBT</a> configured with
<ahref="../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, <codeclass="literal">DB_BUFFER_SMALL</code>,
that is returned in this case.</p>
<p>The reason for the change is that the use of <spanclass="bold"><strong>ENOMEM</strong></span> was
ambiguous: calls such as <ahref="../api_reference/C/dbget.html"class="olink">DB->get()</a> or <ahref="../api_reference/C/dbcget.html"class="olink">DBC->get()</a> could return
<spanclass="bold"><strong>ENOMEM</strong></span> either if a <ahref="../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 <spanclass="bold"><strong>ENOMEM</strong></span> as a fatal error. Code that checked for
the <spanclass="bold"><strong>ENOMEM</strong></span> return and allocated a new buffer should be changed
to check for <codeclass="literal">DB_BUFFER_SMALL</code>.</p>
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 <spanclass="bold"><strong>DbMemoryException</strong></span> will be thrown when a <spanclass="bold"><strong>Dbt</strong></span> is too small to hold a return value, and an <spanclass="bold"><strong>OutOfMemoryError</strong></span> will be thrown in all cases of resource exhaustion.</p>