Small, Fast, Reliable.
Choose any three.

About Sitemap Documentation Download License News Developers Support

## SQLite C Interface

### Memory Allocation Subsystem

>     void *sqlite3_malloc(int);
>     void *sqlite3_realloc(void*, int);
>     void sqlite3_free(void*);

The SQLite core uses these three routines for all of its own internal memory allocation needs. (See the exception below.)

The default implementation of the memory allocation subsystem uses the malloc(), realloc() and free() provided by the standard C library. However, if SQLite is compiled with the following C preprocessor macro

> SQLITE_MEMORY_SIZE=NNN

where NNN is an integer, then SQLite create a static array of at least NNN bytes in size and use that array for all of its dynamic memory allocation needs.

In SQLite version 3.5.0 and 3.5.1, it was possible to define the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in implementation of these routines to be omitted. That capability is no longer provided. Only built-in memory allocators can be used.

Exception: The windows OS interface layer calls the system malloc() and free() directly when converting filenames between the UTF-8 encoding used by SQLite and whatever filename encoding is used by the particular windows installation. Memory allocation errors are detected, but they are reported back as SQLITE_CANTOPEN or SQLITE_IOERR rather than SQLITE_NOMEM.

See also lists of Objects, Constants, and Functions.

This page last modified 2007/11/22 00:41:31 UTC