ENOMEM and DbMemoryException
Prev | Chapter 7. Upgrading Berkeley DB 4.2 applications to Berkeley DB 4.3 | Next

## ENOMEM and DbMemoryException

In versions of Berkeley DB before 4.3, the error ENOMEM was used to indicate that the buffer in a DBT configured with DB_DBT_USERMEM was too small to hold a key or data item being retrieved. The 4.3 release adds a new error, `DB_BUFFER_SMALL`, that is returned in this case.

The reason for the change is that the use of ENOMEM was ambiguous: calls such as DB->get() or DBC->get() could return ENOMEM either if a DBT was too small or if some resource was exhausted.

The result is that starting with the 4.3 release, C applications should always treat ENOMEM as a fatal error. Code that checked for the ENOMEM return and allocated a new buffer should be changed to check for `DB_BUFFER_SMALL`.

In C++ applications configured for exceptions, a DbMemoryException will continue to be thrown in both cases, and applications should check the errno in the exception to determine which error occurred.

In Java applications, a DbMemoryException will be thrown when a Dbt is too small to hold a return value, and an OutOfMemoryError will be thrown in all cases of resource exhaustion.

Prev | Up | Next
DB_FILEOPEN | Home | Replication