Library Version 11.2.5.3

Db::set_heapsize()
Prev | Chapter 2. The Db Handle | Next

## Db::set_heapsize()

    #include <db_cxx.h>

    int
    Db::set_heapsize(u_int32_t gbytes, u_int32_t bytes, u_int32_t flags);

Sets the maximum on-disk database file size used by a database configured to use the Heap access method. If this method is never called, the database's file size can grow without bound. If this method is called, then the heap file can never grow larger than the limit defined by this method. In that case, attempts to update or create records in a Heap database that has reached its maximum size will result in a `DB_HEAP_FULL` error return.

The size specified to this method must be at least three times the database page size. That is, a Heap database must contain at least three database pages. You can set the database page size using the Db::set_pagesize() method.

The `Db::set_heapsize()` method may not be called after the Db::open() method is called. Further, if this method is called on an existing Heap database, the size specified here must match the size used to create the database. Note, however, that specifying an incorrect size to this method will not result in an error return (`EINVAL`) until the database is opened.

The `Db::set_heapsize()` method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

### Parameters

#### gbytes

The size of the heap is set to gbytes gigabytes plus bytes.

#### bytes

The size of the heap is set to gbytes gigabytes plus bytes.

#### flags

The flags parameter is currently unused, and must be set to 0.

### Errors

The `Db::set_heapsize()` method may fail and throw a DbException exception, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:

#### EINVAL

If the specified heap size was too small; the method was called after Db::open() was called; or if an invalid flag value or parameter was specified.

### Class

Db

### See Also

Database and Related Methods

Prev | Up | Next
Db::set_h_nelem() | Home | Db::set_heap_regionsize()